From 3e13e69724a116c7998258c0cd0839699df85a82 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 24 Mar 2024 22:01:56 +0800 Subject: [PATCH] BufFix: avoid may change data in splitter --- src/Http/HttpRequestSplitter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Http/HttpRequestSplitter.cpp b/src/Http/HttpRequestSplitter.cpp index 32ab476f..9cc4cfcb 100644 --- a/src/Http/HttpRequestSplitter.cpp +++ b/src/Http/HttpRequestSplitter.cpp @@ -65,18 +65,18 @@ void HttpRequestSplitter::input(const char *data,size_t len) { _content_len = onRecvHeader(header_ptr, header_size); } - if(_remain_data_size <= 0){ - //没有剩余数据,清空缓存 - _remain_data.clear(); - return; - } - /* * 恢复末尾字节 * 移动到这来,目的是防止HttpRequestSplitter::reset()导致内存失效 */ tail_ref = tail_tmp; + if(_remain_data_size <= 0){ + //没有剩余数据,清空缓存 + _remain_data.clear(); + return; + } + if(_content_len == 0){ //尚未找到http头,缓存定位到剩余数据部分 _remain_data.assign(ptr,_remain_data_size);