mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-08 02:48: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->hasdefault ||
|
||||||
first_arg->numtags != 1)
|
first_arg->numtags != 1)
|
||||||
{
|
{
|
||||||
|
free(method);
|
||||||
error(108, spectype, map->name);
|
error(108, spectype, map->name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -3598,7 +3599,7 @@ static void domethodmap(LayoutSpec spec)
|
|||||||
|
|
||||||
needtoken(tTERM);
|
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) {
|
if (!methods) {
|
||||||
error(123);
|
error(123);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -2612,6 +2612,29 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
|
|||||||
constvalue *stateptr;
|
constvalue *stateptr;
|
||||||
int mustdelete;
|
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
|
/* erase only the symbols with a deeper nesting level than the
|
||||||
* specified nesting level */
|
* specified nesting level */
|
||||||
while (root->next!=NULL) {
|
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);
|
assert(sym->parent==NULL);
|
||||||
break;
|
break;
|
||||||
case iPROXY:
|
case iPROXY:
|
||||||
mustdelete=delete_functions || (sym->target->usage & uNATIVE)!=0;
|
// Original loop determined it was okay to keep.
|
||||||
|
mustdelete=FALSE;
|
||||||
break;
|
break;
|
||||||
case iARRAYCELL:
|
case iARRAYCELL:
|
||||||
case iARRAYCHAR:
|
case iARRAYCHAR:
|
||||||
|
|||||||
@ -484,6 +484,8 @@ void methodmaps_free()
|
|||||||
methodmap_t *ptr = methodmap_first;
|
methodmap_t *ptr = methodmap_first;
|
||||||
while (ptr) {
|
while (ptr) {
|
||||||
methodmap_t *next = ptr->next;
|
methodmap_t *next = ptr->next;
|
||||||
|
for (size_t i = 0; i < ptr->nummethods; i++)
|
||||||
|
free(ptr->methods[i]);
|
||||||
free(ptr->methods);
|
free(ptr->methods);
|
||||||
free(ptr);
|
free(ptr);
|
||||||
ptr = next;
|
ptr = next;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user