Use malloc in parse_save to avoid stack overflow
918 KiB arrays should not be allocated on the stack...
This commit is contained in:
parent
2f594c6bf1
commit
9b83bf27a8
@ -533,8 +533,9 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
|
|||||||
unsigned char *d=NULL,*c=save;
|
unsigned char *d=NULL,*c=save;
|
||||||
int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0, tempGrav = 0;
|
int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0, tempGrav = 0;
|
||||||
int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h;
|
int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h;
|
||||||
int fp[NPART], nf=0, new_format = 0, ttv = 0;
|
int nf=0, new_format = 0, ttv = 0;
|
||||||
particle *parts = partsptr;
|
particle *parts = partsptr;
|
||||||
|
int *fp = malloc(NPART*sizeof(int));
|
||||||
|
|
||||||
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures
|
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures
|
||||||
//This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
|
//This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
|
||||||
@ -1046,12 +1047,14 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
|
|||||||
version1:
|
version1:
|
||||||
if (m) free(m);
|
if (m) free(m);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
|
if (fp) free(fp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
corrupt:
|
corrupt:
|
||||||
if (m) free(m);
|
if (m) free(m);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
|
if (fp) free(fp);
|
||||||
if (replace)
|
if (replace)
|
||||||
{
|
{
|
||||||
legacy_enable = 0;
|
legacy_enable = 0;
|
||||||
|
Reference in New Issue
Block a user