Don't attempt to create a string from nullptr if demangling fails
@@ -8,7 +8,10 @@ namespace vespalib {
string demangle(const char * native) {
int status = 0;
size_t size = 0;
- char *unmangled = abi::__cxa_demangle(native, 0, &size, &status);
+ char *unmangled = abi::__cxa_demangle(native, nullptr, &size, &status);
+ if (unmangled == nullptr) {
+ return ""; // Demangling failed for some reason. TODO return `native` instead?
+ }
string result(unmangled);
free(unmangled);
return result;
