Skip to content
Snippets Groups Projects
Commit 18af43a4 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Address Coverity defects.

parent f650a5ed
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -971,6 +971,9 @@ char* read_diz(const char* path, struct sauce_charinfo* sauce) ...@@ -971,6 +971,9 @@ char* read_diz(const char* path, struct sauce_charinfo* sauce)
memset(sauce, 0, sizeof(*sauce)); memset(sauce, 0, sizeof(*sauce));
off_t len = flength(path); off_t len = flength(path);
if(len < 1)
return NULL;
FILE* fp = fopen(path, "rb"); FILE* fp = fopen(path, "rb");
if(fp == NULL) if(fp == NULL)
return NULL; return NULL;
...@@ -982,13 +985,15 @@ char* read_diz(const char* path, struct sauce_charinfo* sauce) ...@@ -982,13 +985,15 @@ char* read_diz(const char* path, struct sauce_charinfo* sauce)
len = LEN_EXTDESC; len = LEN_EXTDESC;
char* buf = calloc((size_t)len + 1, 1); char* buf = calloc((size_t)len + 1, 1);
if(buf != NULL) if(buf != NULL) {
fread(buf, (size_t)len, 1, fp); size_t rd = fread(buf, 1, (size_t)len, fp);
buf[rd] = 0;
char* eof = strchr(buf, CTRL_Z); // CP/M EOF
if(eof != NULL)
*eof = '\0';
}
fclose(fp); fclose(fp);
char* eof = strchr(buf, CTRL_Z); // CP/M EOF
if(eof != NULL)
*eof = '\0';
return buf; return buf;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment