parent
044df14616
commit
3ce393f511
@ -0,0 +1,58 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
void crashgetc() {
|
||||
|
||||
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
f=fopen("this_file_doesnt_exists", "r");
|
||||
i =getc(f);
|
||||
printf("i =%i\n", i);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void nocrashgetc() {
|
||||
|
||||
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
f=fopen("this_file_doesnt_exists", "r");
|
||||
|
||||
|
||||
if (f) {
|
||||
i =getc(f);
|
||||
printf("i =%i\n", i);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
void crashfgetc() {
|
||||
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
f=fopen("this_file_doesnt_exists", "r");
|
||||
i =fgetc(f);
|
||||
printf("i =%i\n", i);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void nocrashfgetc() {
|
||||
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
f=fopen("this_file_doesnt_exists", "r");
|
||||
if (f) {
|
||||
i =fgetc(f);
|
||||
printf("i =%i\n", i);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2013- Facebook.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package endtoend.c;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
||||
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class NullDereferenceTest2 {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"null_dereference/get.c";
|
||||
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadCInferResults(
|
||||
NullDereferenceTest2.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void nullDereferenceTest2() throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain null pointer dereference error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
SOURCE_FILE,
|
||||
"crashgetc"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullDereferenceTest2_fgetc() throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain null pointer dereference error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
SOURCE_FILE,
|
||||
"crashfgetc"
|
||||
)
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in new issue