forked from OSchip/llvm-project
[asan] fix fopen interceptor to not crash if path is NULL
llvm-svn: 256182
This commit is contained in:
parent
8614dd7e19
commit
1d1be3dd88
|
@ -4769,7 +4769,7 @@ INTERCEPTOR(int, __woverflow, __sanitizer_FILE *fp, int ch) {
|
|||
INTERCEPTOR(__sanitizer_FILE *, fopen, const char *path, const char *mode) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, fopen, path, mode);
|
||||
COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
|
||||
if (path) COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
|
||||
COMMON_INTERCEPTOR_READ_RANGE(ctx, mode, REAL(strlen)(mode) + 1);
|
||||
__sanitizer_FILE *res = REAL(fopen)(path, mode);
|
||||
COMMON_INTERCEPTOR_FILE_OPEN(ctx, res, path);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// Check that fopen(NULL, "r") is ok.
|
||||
// RUN: %clang -O2 %s -o %t && %run %t
|
||||
#include <stdio.h>
|
||||
const char *fn = NULL;
|
||||
FILE *f;
|
||||
int main() { f = fopen(fn, "r"); }
|
Loading…
Reference in New Issue