Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit a5766b7

Browse files
committed
Fix occasional segmentation fault for free_symbol
When processing functions with variable arguments, the 'numdim' and 'dimnames' parameters of s_arginfo aren't set or cleared. Due to a malloc (w/ no memory clear), this can cause a segmentation fault when attempting to free the symbol.
1 parent 4afc437 commit a5766b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/sc1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3435,7 +3435,7 @@ SC_FUNC symbol *fetchfunc(const char *name,int tag)
34353435
sym=addsym(name,code_idx,iFUNCTN,sGLOBAL,tag,0);
34363436
assert(sym!=NULL); /* fatal error 103 must be given on error */
34373437
/* assume no arguments */
3438-
sym->dim.arglist=(arginfo*)malloc(1*sizeof(arginfo));
3438+
sym->dim.arglist=(arginfo*)calloc(1, sizeof(arginfo));
34393439
sym->dim.arglist[0].ident=0;
34403440
/* set library ID to NULL (only for native functions) */
34413441
sym->x.lib=NULL;
@@ -4233,7 +4233,7 @@ static int declargs(symbol *sym,int chkshadow)
42334233
int argcnt,oldargcnt,tok,numtags;
42344234
int tags[MAXTAGS];
42354235
cell val;
4236-
arginfo arg;
4236+
arginfo arg = { 0 };
42374237
arginfo *arglist;
42384238
char name[sNAMEMAX+1];
42394239
int ident,fpublic,fconst;

0 commit comments

Comments
 (0)