stransport memory management improvements#3891
Conversation
de30549 to
368f7b4
Compare
There was a problem hiding this comment.
When would this be NULL? If we fail to create the context, we error out on the constructor itself.
There was a problem hiding this comment.
Agreed. The only reasoning behind this was as a safeguard. Anyway, might as well just drop it if you deem this to be unnecessary. The other fix is still valid, I guess.
There was a problem hiding this comment.
It's either this or the other block. With this patch we avoid calling the free function when it's NULL so it's either one or the other.
There was a problem hiding this comment.
Okay, I've dropped this patch. Note though that previously we haven't been calling the free function either, as at the point of time when calling it we didn't yet initialize the free function pointer.
When failing to initialize a new stransport stream, we try to release already allocated memory by calling out to `git_stream_free`, which in turn called out to the stream's `free` function pointer. As we only initialize the function pointer later on, this leads to a `NULL` pointer exception. Furthermore, plug another memory leak when failing to create the SSL context.
368f7b4 to
b989514
Compare

Some fixes to memory management I've encountered when reasoning about #3885. While these fixes probably won't fix the problems encountered in this ticket, I think they are a worthwhile improvement never the less.