forked from github/server
CID 22443 Ignoring number of bytes read
This commit is contained in:
parent
870d42ccfe
commit
f78fe84216
|
@ -35,6 +35,7 @@ static int tolua_storage_create(lua_State * L)
|
||||||
const char *type = tolua_tostring(L, 2, "rb");
|
const char *type = tolua_tostring(L, 2, "rb");
|
||||||
FILE * F;
|
FILE * F;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
size_t sz;
|
||||||
|
|
||||||
F = fopen(filename, type);
|
F = fopen(filename, type);
|
||||||
if (F) {
|
if (F) {
|
||||||
|
@ -42,9 +43,14 @@ static int tolua_storage_create(lua_State * L)
|
||||||
storage *store = (storage *)calloc(1, sizeof(storage));
|
storage *store = (storage *)calloc(1, sizeof(storage));
|
||||||
data->store = store;
|
data->store = store;
|
||||||
if (strchr(type, 'r')) {
|
if (strchr(type, 'r')) {
|
||||||
fread(&data->version, sizeof(int), 1, F);
|
sz = fread(&data->version, sizeof(int), 1, F);
|
||||||
|
if (sz != sizeof(int)) {
|
||||||
|
err = ferror(F);
|
||||||
|
}
|
||||||
|
else {
|
||||||
err = fseek(F, sizeof(int), SEEK_CUR);
|
err = fseek(F, sizeof(int), SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (strchr(type, 'w')) {
|
else if (strchr(type, 'w')) {
|
||||||
int n = STREAM_VERSION;
|
int n = STREAM_VERSION;
|
||||||
data->version = RELEASE_VERSION;
|
data->version = RELEASE_VERSION;
|
||||||
|
|
Loading…
Reference in New Issue