mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Add string and symbol guard allocation paranoia
This commit is contained in:
6
symbol.c
6
symbol.c
@@ -110,7 +110,7 @@ addglobal(char *name, BOOL isstatic)
|
||||
return NULL;
|
||||
hp = &globalhash[HASHSYM(name, len)];
|
||||
for (sp = *hp; sp; sp = sp->g_next) {
|
||||
if ((sp->g_len == len) && (strcmp(sp->g_name, name) == 0)
|
||||
if ((sp->g_len == len) && (strncmp(sp->g_name, name, len+1) == 0)
|
||||
&& (sp->g_filescope == newfilescope)
|
||||
&& (sp->g_funcscope == newfuncscope))
|
||||
return sp;
|
||||
@@ -145,8 +145,8 @@ findglobal(char *name)
|
||||
|
||||
bestsp = NULL;
|
||||
len = strlen(name);
|
||||
for (sp = globalhash[HASHSYM(name, len)]; sp; sp = sp->g_next) {
|
||||
if ((sp->g_len == len) && !strcmp(sp->g_name, name)) {
|
||||
for (sp = globalhash[HASHSYM(name, len)]; sp != NULL; sp = sp->g_next) {
|
||||
if ((sp->g_len == len) && (strncmp(sp->g_name, name, len+1) == 0)) {
|
||||
if ((bestsp == NULL) ||
|
||||
(sp->g_filescope > bestsp->g_filescope) ||
|
||||
(sp->g_funcscope > bestsp->g_funcscope))
|
||||
|
Reference in New Issue
Block a user