mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
a few calloc checks, still many to go
This commit is contained in:
parent
74c60301d1
commit
c37ca881e6
12 changed files with 84 additions and 1 deletions
|
@ -1360,7 +1360,7 @@ int json_prettify(const char *s, int len, struct json_out *out) {
|
|||
int json_prettify_file(const char *file_name) WEAK;
|
||||
int json_prettify_file(const char *file_name) {
|
||||
int res = -1;
|
||||
char *s = json_fread(file_name);
|
||||
const char *s = json_fread(file_name);
|
||||
FILE *fp;
|
||||
if (s != NULL && (fp = fopen(file_name, "wb")) != NULL) {
|
||||
struct json_out out = JSON_OUT_FILE(fp);
|
||||
|
@ -1369,6 +1369,9 @@ int json_prettify_file(const char *file_name) {
|
|||
/* On error, restore the old content */
|
||||
fclose(fp);
|
||||
fp = fopen(file_name, "wb");
|
||||
if (fp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
fwrite(s, 1, strlen(s), fp);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue