The following patch fixes a number of possible memory leaks that are caused by overwritting of the original pointer.
David Kahurani (1): tools/winedump : Avoid potential memory leaks
tools/winedump/msmangle.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
ct->expression gets overwritten with each call to strmake. Save its address in a temporary variable inorder to free it later on and avoid a memory leak --- tools/winedump/msmangle.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/winedump/msmangle.c b/tools/winedump/msmangle.c index cf26a07..5ccf430 100644 --- a/tools/winedump/msmangle.c +++ b/tools/winedump/msmangle.c @@ -533,7 +533,6 @@ static char *demangle_datatype (char **str, compound_type *ct, if (*iter == '6') { int sub_expressions = 0; - /* FIXME: there are tons of memory leaks here */ /* FIXME: this is still broken in some cases and it has to be * merged with the function prototype parsing above... */ @@ -550,15 +549,21 @@ static char *demangle_datatype (char **str, compound_type *ct, if (!demangle_datatype (&iter, &sub_ct, sym)) return NULL; if (sub_expressions) + char *tmp = ct->expression; ct->expression = strmake( "%s, %s", ct->expression, sub_ct.expression ); + free(tmp); else + char *tmp = ct->expression; ct->expression = strmake( "%s%s", ct->expression, sub_ct.expression ); + free(tmp); while (*iter == '@') iter++; sub_expressions++; } } else while (*iter == '@') iter++; iter++; + char *tmp = ct->expression; ct->expression = strmake( "%s)", ct->expression ); + free(tmp); } else return NULL;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=99778
Your paranoid android.
=== debiant2 (build log) ===
../wine/tools/winedump/msmangle.c:550:27: error: expected expression before ‘char’ ../wine/tools/winedump/msmangle.c:552:32: error: ‘tmp’ undeclared (first use in this function); did you mean ‘tm’? ../wine/tools/winedump/msmangle.c:553:9: error: ‘else’ without a previous ‘if’ Task: The win32 Wine build failed
=== debiant2 (build log) ===
../wine/tools/winedump/msmangle.c:550:27: error: expected expression before ‘char’ ../wine/tools/winedump/msmangle.c:552:32: error: ‘tmp’ undeclared (first use in this function); did you mean ‘tm’? ../wine/tools/winedump/msmangle.c:553:9: error: ‘else’ without a previous ‘if’ Task: The wow64 Wine build failed