mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-07 10:28:34 +00:00
Fix varying levels of stupid memory errors.
This commit is contained in:
parent
b0773d7be4
commit
f2e166c592
@ -3504,6 +3504,7 @@ methodmap_method_t *parse_method(methodmap_t *map)
|
||||
first_arg->hasdefault ||
|
||||
first_arg->numtags != 1)
|
||||
{
|
||||
free(method);
|
||||
error(108, spectype, map->name);
|
||||
return NULL;
|
||||
}
|
||||
@ -3598,7 +3599,7 @@ static void domethodmap(LayoutSpec spec)
|
||||
|
||||
needtoken(tTERM);
|
||||
|
||||
methods = (methodmap_method_t **)realloc(map->methods, sizeof(methodmap_method_t *) * map->nummethods);
|
||||
methods = (methodmap_method_t **)realloc(map->methods, sizeof(methodmap_method_t *) * (map->nummethods + 1));
|
||||
if (!methods) {
|
||||
error(123);
|
||||
return;
|
||||
|
||||
@ -2612,6 +2612,29 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
|
||||
constvalue *stateptr;
|
||||
int mustdelete;
|
||||
|
||||
// Hack - proxies have a "target" pointer, but the target could be deleted
|
||||
// already if done inside the main loop below. To get around this we do a
|
||||
// precursor pass. Note that proxies can only be at the global scope.
|
||||
if (origRoot == &glbtab) {
|
||||
symbol *iter = root;
|
||||
while (iter->next) {
|
||||
sym = iter->next;
|
||||
|
||||
if (sym->ident != iPROXY) {
|
||||
iter = sym;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (delete_functions || (sym->target->usage & uNATIVE) != 0) {
|
||||
RemoveFromHashTable(sp_Globals, sym);
|
||||
iter->next = sym->next;
|
||||
free_symbol(sym);
|
||||
} else {
|
||||
iter = sym;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* erase only the symbols with a deeper nesting level than the
|
||||
* specified nesting level */
|
||||
while (root->next!=NULL) {
|
||||
@ -2655,7 +2678,8 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
|
||||
assert(sym->parent==NULL);
|
||||
break;
|
||||
case iPROXY:
|
||||
mustdelete=delete_functions || (sym->target->usage & uNATIVE)!=0;
|
||||
// Original loop determined it was okay to keep.
|
||||
mustdelete=FALSE;
|
||||
break;
|
||||
case iARRAYCELL:
|
||||
case iARRAYCHAR:
|
||||
|
||||
@ -484,6 +484,8 @@ void methodmaps_free()
|
||||
methodmap_t *ptr = methodmap_first;
|
||||
while (ptr) {
|
||||
methodmap_t *next = ptr->next;
|
||||
for (size_t i = 0; i < ptr->nummethods; i++)
|
||||
free(ptr->methods[i]);
|
||||
free(ptr->methods);
|
||||
free(ptr);
|
||||
ptr = next;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user