diff --git a/main.cpp b/main.cpp index f9ee4c1..0724a19 100644 --- a/main.cpp +++ b/main.cpp @@ -20,12 +20,17 @@ bool must_link = false; char *getBufferFromFile(const char* filename) { FILE *f = fopen(filename, "rb"); + if (!f) { + perror("Error opening file"); + exit(-1); + } fseek(f, 0, SEEK_END); long size = ftell(f); fseek(f, 0, SEEK_SET); char *buffer = (char*)malloc(size+1); fread(buffer, size, 1, f); buffer[size] = 0; + fclose(f); return buffer; }