Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Feb 2020 21:15:52 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357535 - head/contrib/elftoolchain/libelftc
Message-ID:  <202002042115.014LFqgQ018968@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Feb  4 21:15:52 2020
New Revision: 357535
URL: https://svnweb.freebsd.org/changeset/base/357535

Log:
  libelftc: Fix memory leaks in the C++ demanglers.
  
  CID:		1262518, 1262519, 1262520, 1262529
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/contrib/elftoolchain/libelftc/libelftc_dem_arm.c
  head/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c

Modified: head/contrib/elftoolchain/libelftc/libelftc_dem_arm.c
==============================================================================
--- head/contrib/elftoolchain/libelftc/libelftc_dem_arm.c	Tue Feb  4 21:15:29 2020	(r357534)
+++ head/contrib/elftoolchain/libelftc/libelftc_dem_arm.c	Tue Feb  4 21:15:52 2020	(r357535)
@@ -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;

Modified: head/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c
==============================================================================
--- head/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c	Tue Feb  4 21:15:29 2020	(r357534)
+++ head/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c	Tue Feb  4 21:15:52 2020	(r357535)
@@ -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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002042115.014LFqgQ018968>