Make fread call error handle
This commit is contained in:
+8
-1
@@ -15,7 +15,14 @@ int main(int argc, char *argv[]) {
|
|||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
char *script_content = (char *)malloc(size + 1);
|
char *script_content = (char *)malloc(size + 1);
|
||||||
fread(script_content, 1, size, file);
|
size_t read = fread(script_content, 1, size, file);
|
||||||
|
|
||||||
|
if (read != size) {
|
||||||
|
fprintf(stderr, "Failed to read startup script: %s\n", startup_script);
|
||||||
|
free(script_content);
|
||||||
|
fclose(file);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
script_content[size] = '\0';
|
script_content[size] = '\0';
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user