debuginfod: Clear and reset debuginfod_client winning_headers on reuse
Commit Message
gcc address sanitizer detected a leak of the debuginfod_client
winning_headers when the handle was reused. Make sure to free and
reset the winning_headers field before reuse.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
debuginfod/ChangeLog | 5 +++++
debuginfod/debuginfod-client.c | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
Comments
Hi -
> gcc address sanitizer detected a leak of the debuginfod_client
> winning_headers when the handle was reused. Make sure to free and
> reset the winning_headers field before reuse.
This is good.
(Note we're not actually using these winning_headers bits for
anything. That was to be part of the "return headers to application"
work whose API we were discussing under PR28284. I suspect it'll come
to a more thorough motivation & understanding when we try to work out
PR28204 - passing file signatures).
- FChE
Hi Frank,
On Mon, 2021-12-06 at 13:41 -0500, Frank Ch. Eigler wrote:
> gcc address sanitizer detected a leak of the debuginfod_client
> > winning_headers when the handle was reused. Make sure to free and
> > reset the winning_headers field before reuse.
>
> This is good.
Thanks, pushed.
Cheers,
Mark
@@ -1,3 +1,8 @@
+2021-12-04 Mark Wielaard <mark@klomp.org>
+
+ * debuginfod-client.c (debuginfod_query_server): Free winning_headers.
+ Reset response_data_size when clearing response_data.
+
2021-12-04 Mark Wielaard <mark@klomp.org>
* debuginfod.cxx (main): Call debuginfod_pool_groom before exit.
@@ -1028,7 +1028,11 @@ debuginfod_query_server (debuginfod_client *c,
int committed_to = -1;
bool verbose_reported = false;
struct timespec start_time, cur_time;
- c->winning_headers = NULL;
+ if (c->winning_headers != NULL)
+ {
+ free (c->winning_headers);
+ c->winning_headers = NULL;
+ }
if ( maxtime > 0 && clock_gettime(CLOCK_MONOTONIC_RAW, &start_time) == -1)
{
rc = errno;
@@ -1072,6 +1076,7 @@ debuginfod_query_server (debuginfod_client *c,
if (vfd >= 0 && c->winning_headers != NULL)
dprintf(vfd, "\n%s", c->winning_headers);
data[committed_to].response_data = NULL;
+ data[committed_to].response_data_size = 0;
}
}