mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-11 10:26:44 +00:00
[sanitizer] Fix mallopt interceptor.
On error, mallopt is supposed to return 0, not -1. llvm-svn: 345323
This commit is contained in:
parent
018b0634b4
commit
ea857e8225
@ -209,7 +209,7 @@ INTERCEPTOR(struct fake_mallinfo, mallinfo, void) {
|
||||
}
|
||||
|
||||
INTERCEPTOR(int, mallopt, int cmd, int value) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
|
||||
|
||||
|
@ -186,7 +186,7 @@ struct __sanitizer_struct_mallinfo __sanitizer_mallinfo() {
|
||||
}
|
||||
|
||||
int __sanitizer_mallopt(int cmd, int value) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __sanitizer_malloc_stats(void) {
|
||||
|
@ -153,7 +153,7 @@ INTERCEPTOR(struct fake_mallinfo, mallinfo, void) {
|
||||
#define LSAN_MAYBE_INTERCEPT_MALLINFO INTERCEPT_FUNCTION(mallinfo)
|
||||
|
||||
INTERCEPTOR(int, mallopt, int cmd, int value) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#define LSAN_MAYBE_INTERCEPT_MALLOPT INTERCEPT_FUNCTION(mallopt)
|
||||
#else
|
||||
|
@ -265,7 +265,7 @@ INTERCEPTOR(void, mallinfo, __sanitizer_struct_mallinfo *sret) {
|
||||
|
||||
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
|
||||
INTERCEPTOR(int, mallopt, int cmd, int value) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#define MSAN_MAYBE_INTERCEPT_MALLOPT INTERCEPT_FUNCTION(mallopt)
|
||||
#else
|
||||
|
@ -79,7 +79,7 @@ INTERCEPTOR_ATTRIBUTE size_t malloc_usable_size(void *ptr) {
|
||||
|
||||
#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
|
||||
INTERCEPTOR_ATTRIBUTE int mallopt(int cmd, int value) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
} // extern "C"
|
||||
|
@ -0,0 +1,9 @@
|
||||
// Check that mallopt does not return invalid values (ex. -1).
|
||||
// RUN: %clangxx -O2 %s -o %t && %run %t
|
||||
#include <assert.h>
|
||||
#include <malloc.h>
|
||||
|
||||
int main() {
|
||||
int res = mallopt(M_ARENA_MAX, 0);
|
||||
assert(res == 0 || res == 1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user