mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
Fix file descriptor leak and error handling
This commit is contained in:
parent
2bf8c2c130
commit
6eb996540c
@ -193,12 +193,12 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
|
|||||||
buf[9] = '\0';
|
buf[9] = '\0';
|
||||||
if (memcmp(buf,"REDIS",5) != 0) {
|
if (memcmp(buf,"REDIS",5) != 0) {
|
||||||
rdbCheckError("Wrong signature trying to load DB from file");
|
rdbCheckError("Wrong signature trying to load DB from file");
|
||||||
return 1;
|
goto err;
|
||||||
}
|
}
|
||||||
rdbver = atoi(buf+5);
|
rdbver = atoi(buf+5);
|
||||||
if (rdbver < 1 || rdbver > RDB_VERSION) {
|
if (rdbver < 1 || rdbver > RDB_VERSION) {
|
||||||
rdbCheckError("Can't handle RDB format version %d",rdbver);
|
rdbCheckError("Can't handle RDB format version %d",rdbver);
|
||||||
return 1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
startLoading(fp);
|
startLoading(fp);
|
||||||
@ -270,7 +270,7 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
|
|||||||
} else {
|
} else {
|
||||||
if (!rdbIsObjectType(type)) {
|
if (!rdbIsObjectType(type)) {
|
||||||
rdbCheckError("Invalid object type: %d", type);
|
rdbCheckError("Invalid object type: %d", type);
|
||||||
return 1;
|
goto err;
|
||||||
}
|
}
|
||||||
rdbstate.key_type = type;
|
rdbstate.key_type = type;
|
||||||
}
|
}
|
||||||
@ -307,6 +307,7 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
|
|||||||
rdbCheckInfo("RDB file was saved with checksum disabled: no check performed.");
|
rdbCheckInfo("RDB file was saved with checksum disabled: no check performed.");
|
||||||
} else if (cksum != expected) {
|
} else if (cksum != expected) {
|
||||||
rdbCheckError("RDB CRC error");
|
rdbCheckError("RDB CRC error");
|
||||||
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
rdbCheckInfo("Checksum OK");
|
rdbCheckInfo("Checksum OK");
|
||||||
}
|
}
|
||||||
@ -321,6 +322,8 @@ eoferr: /* unexpected end of file is handled here with a fatal exit */
|
|||||||
} else {
|
} else {
|
||||||
rdbCheckError("Unexpected EOF reading RDB file");
|
rdbCheckError("Unexpected EOF reading RDB file");
|
||||||
}
|
}
|
||||||
|
err:
|
||||||
|
if (closefile) fclose(fp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user