From c3fac2e83fc35ddf239b6aa529f3c693943a14aa Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 11 Aug 2010 15:47:44 +0000 Subject: [PATCH] changed method: void PostMultiParser::ReadContentToFileLoop() previous version was not clean git-svn-id: svn://ttmath.org/publicrep/winix/trunk@634 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/postmultiparser.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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);