projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c1bd1ee
)
asan: fix crash in strdup on malloc failure
author
Dmitry Vyukov
<dvyukov@google.com>
Mon, 20 Feb 2023 10:58:15 +0000
(11:58 +0100)
committer
Dmitry Vyukov
<dvyukov@google.com>
Mon, 20 Feb 2023 14:34:33 +0000
(15:34 +0100)
There are some programs that try to handle all malloc failures.
Let's allow testing of such programs.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D144374
compiler-rt/lib/asan/asan_interceptors.cpp
patch
|
blob
|
history
diff --git
a/compiler-rt/lib/asan/asan_interceptors.cpp
b/compiler-rt/lib/asan/asan_interceptors.cpp
index
8170082
..
a4084c8
100644
(file)
--- a/
compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/
compiler-rt/lib/asan/asan_interceptors.cpp
@@
-453,7
+453,9
@@
INTERCEPTOR(char*, strdup, const char *s) {
}
GET_STACK_TRACE_MALLOC;
void *new_mem = asan_malloc(length + 1, &stack);
- REAL(memcpy)(new_mem, s, length + 1);
+ if (new_mem) {
+ REAL(memcpy)(new_mem, s, length + 1);
+ }
return reinterpret_cast<char*>(new_mem);
}
@@
-469,7
+471,9
@@
INTERCEPTOR(char*, __strdup, const char *s) {
}
GET_STACK_TRACE_MALLOC;
void *new_mem = asan_malloc(length + 1, &stack);
- REAL(memcpy)(new_mem, s, length + 1);
+ if (new_mem) {
+ REAL(memcpy)(new_mem, s, length + 1);
+ }
return reinterpret_cast<char*>(new_mem);
}
#endif // ASAN_INTERCEPT___STRDUP