Exception when de-activating ROSuperHttpChannel


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;
l_responseStream := nil; ← Line added
fOwner.DispatchHTTPRequest(True, l_requestStream, l_responseStream);
fOwner.fState := scNotConnected;

Hope this fix can make it into the source code.


Logged as bugs://D19467.

bugs://D19467 was closed as fixed.