Closed ghost closed 4 years ago
I'm not sure if this issue's still open, but after reading the source code it seems like onion_request_get_language_code(req)
makes a call to strdup
which allocates its bytes.
The reason it would be leaking after each run is because inside the print statement, onion_request_get_language_code(req)
is malloced but has no chance to ever be freed.
I ran it like this
char *value = onion_request_get_language_code(req);
ONION_INFO("%s", value);
if (value)
free(value);
and my leak count is 0.
I don't know if this is the issue or perhaps I'm not understanding something?
Hello,
thank you, this seems to be the issue. Also, it turns out that the main issue is my inability to read as this need to free the result is described in the documentation as well.
I'm really sorry for wasting your time.
Best Regards, Ondřej Fiala
I have discovered that everytime onion_request_get_language_code is called, it leaks a few bytes of data (length apparently depends on the length of the Accept-Language header).
Steps to reproduce:
ONION_INFO("%s", onion_request_get_language_code(req));
into the functionhello
--leak-check=full --show-leak-kinds=all --keep-stacktraces=alloc --track-origins=yes
)definitely lost: 15 bytes in 1 blocks
in its leak summary if yourAccept-Language
header is set to"en-US,en;q=0.5"
, otherwise the size may be different.The number of bytes and the number of blocks shall multiply by the number of requests you make (given that your
Accept-Language
header stays the same).