mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-03 15:58:06 +02:00
Don't leave dangling pointers in Free functions
While these are mostly called during teardown of larger structures that are about to themselves be freed, there's no guarantee that will always be the case, so try to be safer here. [ This bug was found by the Parfait 4.0 bug checking tool. http://labs.oracle.com/pls/apex/f?p=labs:49:::::P49_PROJECT_ID:13 ] v2: Deduplicate & simplify pointer clearing in _XFreeEventCookies as suggested by @keithp Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
parent
7d70e30221
commit
103e2e1151
11 changed files with 17 additions and 3 deletions
|
|
@ -93,6 +93,7 @@ _XimXFreeIntrCallback(
|
|||
Xfree(rec);
|
||||
rec = next;
|
||||
}
|
||||
spec->intr_cb = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ _XimFreeTransIntrCallback(
|
|||
Xfree(rec);
|
||||
rec = next;
|
||||
}
|
||||
spec->intr_cb = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ static void _XFreeContextDB(Display *display)
|
|||
Xfree(db->table);
|
||||
_XFreeMutex(&db->linfo);
|
||||
Xfree(db);
|
||||
display->context_db = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ _XFreeAtomTable(Display *dpy)
|
|||
Xfree(e);
|
||||
}
|
||||
Xfree(dpy->atoms);
|
||||
dpy->atoms = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -911,6 +911,7 @@ _XFreeKeyBindings(
|
|||
Xfree(p->modifiers);
|
||||
Xfree(p);
|
||||
}
|
||||
dpy->key_bindings = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ _XFreeIMFilters(
|
|||
display->im_filters = fl->next;
|
||||
Xfree(fl);
|
||||
}
|
||||
display->im_filters = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -650,11 +650,10 @@ _XFreeEventCookies(Display *dpy)
|
|||
head = (struct stored_event**)&dpy->cookiejar;
|
||||
|
||||
DL_FOREACH_SAFE(*head, e, tmp) {
|
||||
if (dpy->cookiejar == e)
|
||||
dpy->cookiejar = NULL;
|
||||
XFree(e->ev.data);
|
||||
XFree(e);
|
||||
}
|
||||
dpy->cookiejar = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ static void _XFreeMutex(
|
|||
{
|
||||
xmutex_clear(lip->lock);
|
||||
xmutex_free(lip->lock);
|
||||
lip->lock = NULL;
|
||||
}
|
||||
|
||||
#ifdef XTHREADS_WARN
|
||||
|
|
|
|||
|
|
@ -105,4 +105,5 @@ void _XFreeX11XCBStructure(Display *dpy)
|
|||
xcondition_free(dpy->xcb->event_notify);
|
||||
xcondition_free(dpy->xcb->reply_notify);
|
||||
Xfree(dpy->xcb);
|
||||
dpy->xcb = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -612,6 +612,7 @@ _XkbFreeInfo(Display *dpy)
|
|||
if (xkbi->desc)
|
||||
XkbFreeKeyboard(xkbi->desc, XkbAllComponentsMask, True);
|
||||
Xfree(xkbi);
|
||||
dpy->xkb_info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -276,16 +276,22 @@ free_charset(
|
|||
int num;
|
||||
|
||||
Xfree(gen->mb_parse_table);
|
||||
gen->mb_parse_table = NULL;
|
||||
if ((num = gen->mb_parse_list_num) > 0) {
|
||||
for (parse_info = gen->mb_parse_list; num-- > 0; parse_info++) {
|
||||
Xfree((*parse_info)->encoding);
|
||||
Xfree(*parse_info);
|
||||
}
|
||||
Xfree(gen->mb_parse_list);
|
||||
gen->mb_parse_list = NULL;
|
||||
gen->mb_parse_list_num = 0;
|
||||
}
|
||||
|
||||
if ((num = gen->codeset_num) > 0)
|
||||
if ((num = gen->codeset_num) > 0) {
|
||||
Xfree(gen->codeset_list);
|
||||
gen->codeset_list = NULL;
|
||||
gen->codeset_num = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* For VW/UDC */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue