forked from OSchip/llvm-project
[sanitizer] Fix Fuchsia ReadBinaryName not to crash when uninitialized
If the sanitizer runtime is loaded in a binary that doesn't really support it, then __sanitizer_startup_hook will never have been called to initialize StoredArgv. This case can't be supported, but its failure mode shouldn't be to crash in sanitizer_common internals. Patch By: mcgrathr Differential Revision: https://reviews.llvm.org/D46344 llvm-svn: 331382
This commit is contained in:
parent
8d0d1aa229
commit
716d9949f6
|
@ -431,8 +431,10 @@ const char *GetEnv(const char *name) {
|
|||
}
|
||||
|
||||
uptr ReadBinaryName(/*out*/ char *buf, uptr buf_len) {
|
||||
const char *argv0 = StoredArgv[0];
|
||||
if (!argv0) argv0 = "<UNKNOWN>";
|
||||
const char *argv0 = "<UNKNOWN>";
|
||||
if (StoredArgv && StoredArgv[0]) {
|
||||
argv0 = StoredArgv[0];
|
||||
}
|
||||
internal_strncpy(buf, argv0, buf_len);
|
||||
return internal_strlen(buf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue