Merge pull request #66 from rfree-d/fix_string_memory_error_when_frame_ip0

fix off-by-one when resolve goes up to ip==0 frame
This commit is contained in:
François-Xavier Bourlet 2017-07-03 15:08:15 -07:00 committed by GitHub
commit 2c7dfd9e20

View File

@ -752,14 +752,18 @@ public:
while (*funcname && *funcname != '(') {
funcname += 1;
}
trace.object_filename.assign(filename, funcname++);
char* funcname_end = funcname;
while (*funcname_end && *funcname_end != ')' && *funcname_end != '+') {
funcname_end += 1;
trace.object_filename.assign(filename, funcname); // ok even if funcname is the ending \0 (then we assign entire string)
if (*funcname) { // if it's not end of string (e.g. from last frame ip==0)
funcname += 1;
char* funcname_end = funcname;
while (*funcname_end && *funcname_end != ')' && *funcname_end != '+') {
funcname_end += 1;
}
*funcname_end = '\0';
trace.object_function = this->demangle(funcname);
trace.source.function = trace.object_function; // we cannot do better.
}
*funcname_end = '\0';
trace.object_function = this->demangle(funcname);
trace.source.function = trace.object_function; // we cannot do better.
return trace;
}