THRIFT-5088 Memory leak in TWinHttpTransport
Client: Delphi
Patch: Jens Geyer
diff --git a/lib/delphi/src/Thrift.Transport.WinHTTP.pas b/lib/delphi/src/Thrift.Transport.WinHTTP.pas
index 7a1b48f..5794b1c 100644
--- a/lib/delphi/src/Thrift.Transport.WinHTTP.pas
+++ b/lib/delphi/src/Thrift.Transport.WinHTTP.pas
@@ -309,7 +309,7 @@
   http  : IWinHTTPRequest;
   pData : PByte;
   len   : Integer;
-  error : Cardinal;
+  error, dwSize : Cardinal;
   sMsg  : string;
 begin
   http := CreateRequest;
@@ -334,7 +334,8 @@
   end;
 
   FInputStream := THTTPResponseStream.Create( http);
-  UpdateKnownMessageSize( http.QueryTotalResponseSize);
+  if http.QueryTotalResponseSize( dwSize)  // FALSE indicates "no info available"
+  then UpdateKnownMessageSize( dwSize);
 end;
 
 procedure TWinHTTPClientImpl.Write( const pBuf : Pointer; off, len : Integer);