Make fread call error handle

This commit is contained in:
2026-07-26 19:12:32 +01:00
parent 2f70c44ad5
commit f82ab718f3
+8 -1
View File
@@ -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);