Skip to content

Commit 10ab9d2

Browse files
hongjinghaohongjinghao
hongjinghao
authored andcommitted
paramlen has heap memory of length nparam+1. The value of variable i may be greater than nparam+1, causing heap memory overflow. Therefore, i and nparam+1 needs to be determined in the loop. fix:https://bugzilla.nasm.us/show_bug.cgi?id=3392857#c1
1 parent a916e41 commit 10ab9d2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

asm/preproc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6817,7 +6817,7 @@ static int expand_mmacro(Token * tline)
68176817
*/
68186818
nasm_newn(paramlen, nparam+1);
68196819

6820-
for (i = 1; (t = params[i]); i++) {
6820+
for (i = 1; i < nparam+1 && (t = params[i]); i++) {
68216821
bool braced = false;
68226822
int brace = 0;
68236823
int white = 0;

nasmlib/alloc.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ void *nasm_realloc(void *q, size_t size)
104104

105105
void nasm_free(void *q)
106106
{
107-
if (q)
107+
if (q){
108108
free(q);
109+
q = NULL;
110+
}
109111
}
110112

111113
char *nasm_strdup(const char *s)

0 commit comments

Comments
 (0)