Fix possibly unitialized variables in __cxa_demangle_gnu3()

After 0ee0dbfb0d 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
MFC after:	3 days
This commit is contained in:
Dimitry Andric 2021-02-22 21:01:09 +01:00
parent a805ffbcbc
commit d149877758

View File

@ -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;