[asan] Don't crash on fclose(NULL)
It's explicitly forbidden to call fclose with NULL, but at least on Darwin, this succeeds and doesn't segfault. To maintain binary compatibility, ASan should survice fclose(NULL) as well. Differential Revision: https://reviews.llvm.org/D40053 llvm-svn: 319347
This commit is contained in:
		
							parent
							
								
									4d2c703492
								
							
						
					
					
						commit
						e73d1f13b6
					
				| 
						 | 
				
			
			@ -273,7 +273,7 @@ UNUSED static const FileMetadata *GetInterceptorMetadata(
 | 
			
		|||
  MetadataHashMap::Handle h(interceptor_metadata_map, (uptr)addr,
 | 
			
		||||
                            /* remove */ false,
 | 
			
		||||
                            /* create */ false);
 | 
			
		||||
  if (h.exists()) {
 | 
			
		||||
  if (addr && h.exists()) {
 | 
			
		||||
    CHECK(!h.created());
 | 
			
		||||
    CHECK(h->type == CommonInterceptorMetadata::CIMT_FILE);
 | 
			
		||||
    return &h->file;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
// RUN: %clang_asan %s -o %t
 | 
			
		||||
// RUN: %run %t 2>&1 | FileCheck %s
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
int main(int argc, const char * argv[]) {
 | 
			
		||||
  fclose(NULL);
 | 
			
		||||
  fprintf(stderr, "Finished.\n");
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CHECK: Finished.
 | 
			
		||||
		Loading…
	
		Reference in New Issue