diff --git a/core/postmultiparser.cpp b/core/postmultiparser.cpp index db115c9..9059d8a 100755 --- a/core/postmultiparser.cpp +++ b/core/postmultiparser.cpp @@ -265,16 +265,22 @@ void PostMultiParser::ReadContentToFileLoop() bool has_boundary = false; - while( last!=-1 && !(has_boundary=HasBoundary()) ) + while( last!=-1 ) { content += last; content_len += 1; ReadChar(); - if( content.size() > WINIX_POSTMULTI_OUTPUT_BUFFER + boundary.size() + 2 ) // +2 for the new line character + if( HasBoundary() ) { - tmp_file.write(content.c_str(), WINIX_POSTMULTI_OUTPUT_BUFFER); - content.erase(0, WINIX_POSTMULTI_OUTPUT_BUFFER); + has_boundary = true; + break; + } + + if( content.size() >= WINIX_POSTMULTI_OUTPUT_BUFFER ) + { + tmp_file.write(content.c_str(), content.size()); + content.clear(); } if( config->post_file_max != 0 && content_len > (size_t)config->post_file_max ) @@ -303,7 +309,7 @@ void PostMultiParser::ReadContentToFile() time_t t1, t2; content.clear(); - content.reserve(WINIX_POSTMULTI_OUTPUT_BUFFER + boundary.size()); + content.reserve(WINIX_POSTMULTI_OUTPUT_BUFFER); content_len = 0; t1 = time(0);