[Beignet] [PATCHv2] Properly check return value from __cxa_demangle
Jan Beich
jbeich at freebsd.org
Fri Mar 17 14:16:00 UTC 2017
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);
More information about the Beignet
mailing list