Fixed memory leaks in amx_fget* natives
This commit is contained in:
parent
642eb769b2
commit
86b1021f45
@ -406,11 +406,10 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
FILE *fp = (FILE *)params[1];
|
FILE *fp = (FILE *)params[1];
|
||||||
long *t;
|
long t;
|
||||||
t = new long;
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fread(t, sizeof(long), 1, fp);
|
fread(&t, sizeof(long), 1, fp);
|
||||||
return *t;
|
return t;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -418,11 +417,10 @@ static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
FILE *fp = (FILE *)params[1];
|
FILE *fp = (FILE *)params[1];
|
||||||
int *t;
|
int t;
|
||||||
t = new int;
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fread(t, sizeof(int), 1, fp);
|
fread(&t, sizeof(int), 1, fp);
|
||||||
return *t;
|
return t;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -430,11 +428,10 @@ static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
FILE *fp = (FILE *)params[1];
|
FILE *fp = (FILE *)params[1];
|
||||||
short *t;
|
short t;
|
||||||
t = new short;
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fread(t, sizeof(short), 1, fp);
|
fread(&t, sizeof(short), 1, fp);
|
||||||
return *t;
|
return t;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -472,11 +469,10 @@ static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
FILE *fp = (FILE *)params[1];
|
FILE *fp = (FILE *)params[1];
|
||||||
float *t;
|
float t;
|
||||||
t = new float;
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fread(t, sizeof(float), 1, fp);
|
fread(&t, sizeof(float), 1, fp);
|
||||||
return *(cell*)((void *)t);
|
return *(cell*)&t;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user