From: Vitaliy Cherepanov Date: Fri, 13 Dec 2013 11:25:55 +0000 (+0400) Subject: [FIX] fix http client fault X-Git-Tag: Tizen_SDK_2.3~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38d41c9fded087841926abe7f30fb93314e5c1eb;p=platform%2Fcore%2Fsystem%2Fswap-probe.git [FIX] fix http client fault Change-Id: I5f89aa0511b0426051419231f867a0ead4c7cc48 Signed-off-by: Vitaliy Cherepanov --- diff --git a/probe_tizenapi/tizen_http.cpp b/probe_tizenapi/tizen_http.cpp index 7eb5e0c..62e6cad 100755 --- a/probe_tizenapi/tizen_http.cpp +++ b/probe_tizenapi/tizen_http.cpp @@ -292,15 +292,16 @@ Tizen::Base::String* HttpHeader::GetRawHeaderN(void) const GetRawHeaderNp); retVal = (this->*GetRawHeaderNp)(); - if (retVal == NULL) - newerrno = 1; - int bufferSize = retVal->GetLength(); - Tizen::Base::String strData; - strData.SetCapacity(bufferSize); - strData.Append(*retVal); - char* out = new char[bufferSize]; - WcharToChar(out, strData.GetPointer()); + char *out = NULL; + int bufferSize = 0; + if (retVal == NULL) { + newerrno = 1; + } else { + bufferSize = retVal->GetLength(); + out = new char[bufferSize + sizeof(char)]; + WcharToChar(out, retVal->GetPointer()); + } info.msg_buf = out; info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize; @@ -309,7 +310,10 @@ Tizen::Base::String* HttpHeader::GetRawHeaderN(void) const AFTER_ORIGINAL_TIZEN_SOCK("HttpHeader::GetRawHeaderN", VT_NULL, NULL, (unsigned int)this, (unsigned int)this, HTTP_API_RESPONSE, info, "s", "void"); - delete [] out; + + if (out) + delete [] out; + return retVal; } @@ -1741,7 +1745,7 @@ result HttpResponse::WriteBody(const Tizen::Base::ByteBuffer& body) Tizen::Base::String strData; strData.SetCapacity(bufferSize); strData.Append(pBuffer); - char* out = new char[bufferSize]; + char* out = new char[bufferSize + sizeof(char)]; WcharToChar(out, strData.GetPointer()); info.msg_buf = out;