Actually register new plugins and plug a related memory leak

This commit is contained in:
Love Hornquist Astrand
2009-07-19 21:23:56 -07:00
parent 330fd7645d
commit 7e4854250e

View File

@@ -101,6 +101,7 @@ loadlib(krb5_context context, char *path)
e = calloc(1, sizeof(*e)); e = calloc(1, sizeof(*e));
if (e == NULL) { if (e == NULL) {
krb5_set_error_message(context, ENOMEM, "malloc: out of memory"); krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
free(path);
return ENOMEM; return ENOMEM;
} }
@@ -116,7 +117,7 @@ loadlib(krb5_context context, char *path)
e->u.dso.path = path; e->u.dso.path = path;
e->next = registered; e->next = registered;
registered = e->next; registered = e;
return 0; return 0;
} }
@@ -234,10 +235,10 @@ load_plugins(krb5_context context)
for (e = registered; e != NULL; e = e->next) for (e = registered; e != NULL; e = e->next)
if (e->type == DSO && strcmp(e->u.dso.path, path) == 0) if (e->type == DSO && strcmp(e->u.dso.path, path) == 0)
break; break;
if (e == NULL) { if (e) {
ret = loadlib(context, path);
if (ret)
free(path); free(path);
} else {
ret = loadlib(context, path); /* store or frees path */
} }
} }
closedir(d); closedir(d);