forked from github/server
CID 26260: Resource leaks (RESOURCE_LEAK)
This commit is contained in:
parent
db6e9444d6
commit
59069ae342
1 changed files with 18 additions and 19 deletions
|
@ -33,16 +33,13 @@ static int tolua_storage_create(lua_State * L)
|
||||||
{
|
{
|
||||||
const char *filename = tolua_tostring(L, 1, 0);
|
const char *filename = tolua_tostring(L, 1, 0);
|
||||||
const char *type = tolua_tostring(L, 2, "rb");
|
const char *type = tolua_tostring(L, 2, "rb");
|
||||||
gamedata *data = (gamedata *)calloc(1, sizeof(gamedata));
|
|
||||||
storage *store = (storage *)calloc(1, sizeof(storage));
|
|
||||||
FILE * F;
|
FILE * F;
|
||||||
|
|
||||||
data->store = store;
|
|
||||||
|
|
||||||
F = fopen(filename, type);
|
F = fopen(filename, type);
|
||||||
if (!F) {
|
if (!F) {
|
||||||
return 0;
|
gamedata *data = (gamedata *)calloc(1, sizeof(gamedata));
|
||||||
}
|
storage *store = (storage *)calloc(1, sizeof(storage));
|
||||||
|
data->store = store;
|
||||||
if (strchr(type, 'r')) {
|
if (strchr(type, 'r')) {
|
||||||
fread(&data->version, sizeof(int), 1, F);
|
fread(&data->version, sizeof(int), 1, F);
|
||||||
fseek(F, sizeof(int), SEEK_CUR);
|
fseek(F, sizeof(int), SEEK_CUR);
|
||||||
|
@ -57,6 +54,8 @@ static int tolua_storage_create(lua_State * L)
|
||||||
binstore_init(store, &data->strm);
|
binstore_init(store, &data->strm);
|
||||||
tolua_pushusertype(L, (void *)data, TOLUA_CAST "storage");
|
tolua_pushusertype(L, (void *)data, TOLUA_CAST "storage");
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tolua_storage_read_unit(lua_State * L)
|
static int tolua_storage_read_unit(lua_State * L)
|
||||||
|
|
Loading…
Reference in a new issue