[Beignet] [PATCHv2] Properly check return value from __cxa_demangle

Yang, Rong R rong.r.yang at intel.com
Thu Mar 23 07:11:05 UTC 2017


Pushed, thanks.

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Jan Beich
> Sent: Friday, March 17, 2017 22:16
> To: beignet at lists.freedesktop.org
> Cc: Pan, Xiuli <xiuli.pan at intel.com>
> Subject: [Beignet] [PATCHv2] Properly check return value from
> __cxa_demangle
> 
> FreeBSD uses libcxxrt (via libc++) instead of GNU libiberty (via
> libstdc++) for __cxa_demangle(). When *output_buffer* and *length*
> both are NULL it doesn't modify *status* on success. Rather than rely on
> maybe uninitialized variable check the function doesn't return NULL.
> 
> Fixes:		https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213732
> Reviewed-by:	Pan Xiuli <xiuli.pan at intel.com>
> ---
>  backend/src/llvm/llvm_gen_backend.hpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/backend/src/llvm/llvm_gen_backend.hpp
> b/backend/src/llvm/llvm_gen_backend.hpp
> index 1ab77c9d..ae486c5e 100644
> --- a/backend/src/llvm/llvm_gen_backend.hpp
> +++ b/backend/src/llvm/llvm_gen_backend.hpp
> @@ -82,9 +82,9 @@ namespace gbe
>        auto it = map.find(symbol);
> 
>        if (it == map.end()) {
> -        int status;
> +        int status = 0; /* set for libcxxrt */
>          char *realName = abi::__cxa_demangle(symbol.c_str(), NULL, NULL,
> &status);
> -        if (status == 0) {
> +        if (realName) {
>            std::string realFnName(realName), stripName;
>            stripName = realFnName.substr(0, realFnName.find("("));
>            it = map.find(stripName);
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list