Memory leak with do_hset and smash_tilde_copy?
< Newer Topic
:: Older Topic >
Pages:<< prev 1 next >>
#1 Sep 5, 2016 1:43 am
Apprentice
GroupMembers
Posts63
JoinedDec 23, 2007
So, do_hset uses smash_tilde_copy.
smash_tilde_copy uses strdup and returns a pointer to this duplicate string.
do_hset doesn't free this string.
Isn't this a memory leak?
smash_tilde_copy uses strdup and returns a pointer to this duplicate string.
do_hset doesn't free this string.
Isn't this a memory leak?
#2 Sep 5, 2016 11:10 pm
Geomancer
GroupAdministrators
Posts1,946
JoinedJul 26, 2005
great find, feel free to fix it and post a fix for everyone, if you would like to
#3 Sep 7, 2016 6:29 pm
Last edited Sep 7, 2016 6:36 pm by Kasji
Apprentice
GroupMembers
Posts63
JoinedDec 23, 2007
This may be arbitrary as both solutions are "equal" (haven't tested them though). But as far as style or standards goes, which would you consider more conformant?
or
Assuming that this is a standard across all codebases:
I'm compiling on g++ and most of my char * argument's have been turned into const char *.
free(argument);
or
argument = smash_tilde(argument);
Assuming that this is a standard across all codebases:
const char * smash_tilde(const char *);
I'm compiling on g++ and most of my char * argument's have been turned into const char *.
Pages:<< prev 1 next >>