fix a "modify after free" bug which is practically impossible to

experience.

Found by:	Coverity (id #540 #541)
This commit is contained in:
phk 2005-03-26 21:07:35 +00:00
parent f1c38252e6
commit 296d283c83

View File

@ -82,10 +82,11 @@ g_load_class(void *arg, int flag)
hh = arg; hh = arg;
mp = hh->mp; mp = hh->mp;
if (hh->post) hh->error = 0;
if (hh->post) {
g_free(hh); g_free(hh);
else hh = NULL;
hh->error = 0; }
g_trace(G_T_TOPOLOGY, "g_load_class(%s)", mp->name); g_trace(G_T_TOPOLOGY, "g_load_class(%s)", mp->name);
KASSERT(mp->name != NULL && *mp->name != '\0', KASSERT(mp->name != NULL && *mp->name != '\0',
("GEOM class has no name")); ("GEOM class has no name"));
@ -93,12 +94,14 @@ g_load_class(void *arg, int flag)
if (mp2 == mp) { if (mp2 == mp) {
printf("The GEOM class %s is already loaded.\n", printf("The GEOM class %s is already loaded.\n",
mp2->name); mp2->name);
hh->error = EEXIST; if (hh != NULL)
hh->error = EEXIST;
return; return;
} else if (strcmp(mp2->name, mp->name) == 0) { } else if (strcmp(mp2->name, mp->name) == 0) {
printf("A GEOM class %s is already loaded.\n", printf("A GEOM class %s is already loaded.\n",
mp2->name); mp2->name);
hh->error = EEXIST; if (hh != NULL)
hh->error = EEXIST;
return; return;
} }
} }