mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Memory leak: free conn->retbuf in uxagentc.c.
While debugging some new code, I ran valgrind in leak-checking mode and it pointed out a handful of existing memory leaks, which got in the way of spotting any _new_ leaks I might be introducing :-) This was one: in the case where an asynchronous agent query on Unix is aborted, the dynamically allocated buffer holding the response was not freed.
This commit is contained in:
parent
0a0a1c01d7
commit
4d15d46473
@ -95,6 +95,8 @@ void agent_cancel_query(agent_pending_query *conn)
|
||||
uxsel_del(conn->fd);
|
||||
close(conn->fd);
|
||||
del234(agent_pending_queries, conn);
|
||||
if (conn->retbuf && conn->retbuf != conn->sizebuf)
|
||||
sfree(conn->retbuf);
|
||||
sfree(conn);
|
||||
}
|
||||
|
||||
@ -114,11 +116,12 @@ static void agent_select_result(int fd, int event)
|
||||
return; /* more data to come */
|
||||
|
||||
/*
|
||||
* We have now completed the agent query. Do the callback, and
|
||||
* clean up. (Of course we don't free retbuf, since ownership
|
||||
* of that passes to the callback.)
|
||||
* We have now completed the agent query. Do the callback.
|
||||
*/
|
||||
conn->callback(conn->callback_ctx, conn->retbuf, conn->retlen);
|
||||
/* Null out conn->retbuf, since ownership of that buffer has
|
||||
* passed to the callback. */
|
||||
conn->retbuf = NULL;
|
||||
agent_cancel_query(conn);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user