libelftc: Fix memory leaks in the C++ demanglers.

CID:		1262518, 1262519, 1262520, 1262529
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
markj 2020-02-04 21:15:52 +00:00
parent 6f9bba703e
commit 385d20b48b
2 changed files with 9 additions and 5 deletions

View File

@ -203,11 +203,13 @@ cpp_demangle_ARM(const char *org)
break;
if ((arg = vector_str_substr(&d.vec, arg_begin, d.vec.size - 1,
&arg_len)) == NULL)
&arg_len)) == NULL)
goto clean;
if (vector_str_push(&d.arg, arg, arg_len) == false)
if (vector_str_push(&d.arg, arg, arg_len) == false) {
free(arg);
goto clean;
}
free(arg);
@ -956,7 +958,7 @@ read_op_user(struct demangle_data *d)
goto clean;
if (VEC_PUSH_STR(&d->vec, "::operator ") == false)
return (false);
goto clean;
if (vector_str_push(&d->vec, to_str, to_len) == false)
goto clean;

View File

@ -216,11 +216,13 @@ cpp_demangle_gnu2(const char *org)
break;
if ((arg = vector_str_substr(&d.vec, arg_begin, d.vec.size - 1,
&arg_len)) == NULL)
&arg_len)) == NULL)
goto clean;
if (vector_str_push(&d.arg, arg, arg_len) == false)
if (vector_str_push(&d.arg, arg, arg_len) == false) {
free(arg);
goto clean;
}
free(arg);