Exception when de-activating ROSuperHttpChannel

Hi,

I found an issue when terminating a ROSuperHttpChannel. The code in TROSuperHTTPThread.IntExecute might raise an exception:

The problem is when TROSuperHTTPThread.IntExecute calls ‘GoodBye’ and the call to DispatchHTTPRequest is failing. In that scenario, l_responseStream still holds the (invalid) pointer of the previous call to DispatchHTTPRequest which causes FreeOrDisposeOf(l_responseStream) to raise an exception.

I think DispatchHTTPRequest should always initialize the output parameter for the response stream to nil (also when an exception occurs). However for now I fixed the code by adding ‘l_responseStream := nil’ just before calling DispatchHTTPRequest:

if not fSkipGoodbuy then begin // in ServerLocator mode don’t need to send ShGoodbye because server isn’t accessible already
{$IFDEF LOG}Log(‘~~~~> ShGoodbye’);{$ENDIF}
WriteByteToStream(l_requestStream, ShGoodbye, 16);
l_requestStream.Position := 0;
try
l_responseStream := nil; ← Line added
fOwner.DispatchHTTPRequest(True, l_requestStream, l_responseStream);
finally
FreeOrDisposeOf(l_responseStream);
end;
fOwner.fState := scNotConnected;
end;

Hope this fix can make it into the source code.

Thanks

Logged as bugs://D19467.

bugs://D19467 was closed as fixed.