Date: Wed, 24 Feb 2021 19:42:14 GMT From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 696961f67c5e - stable/11 - Fix possibly unitialized variables in __cxa_demangle_gnu3() Message-ID: <202102241942.11OJgELR082887@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/11 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=696961f67c5eaabe03713dbf1b4fc2b7a0ce1cb1 commit 696961f67c5eaabe03713dbf1b4fc2b7a0ce1cb1 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-24 19:40:13 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) --- contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contrib/libcxxrt/libelftc_dem_gnu3.c b/contrib/libcxxrt/libelftc_dem_gnu3.c index 6e88f7b4bb4c..93e1c41fa034 100644 --- a/contrib/libcxxrt/libelftc_dem_gnu3.c +++ b/contrib/libcxxrt/libelftc_dem_gnu3.c @@ -538,8 +538,8 @@ __cxa_demangle_gnu3(const char *org) struct type_delimit td; ssize_t org_len; unsigned int limit; - char *rtn; - bool has_ret, more_type; + char *rtn = NULL; + bool has_ret = false, more_type = false; if (org == NULL) return (NULL); @@ -562,13 +562,9 @@ __cxa_demangle_gnu3(const char *org) return (rtn); } - if (!cpp_demangle_data_init(&ddata, org + 2)) return (NULL); - rtn = NULL; - has_ret = more_type = false; - if (!cpp_demangle_read_encoding(&ddata)) goto clean;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102241942.11OJgELR082887>