forked from Imagelibrary/binutils-gdb
libctf: archive: fix ctf_dict_open_cached error handling
We were misreporting a failure to ctf_dict_open the dict as an out-of-memory error.
This commit is contained in:
@@ -717,7 +717,7 @@ static ctf_dict_t *
|
|||||||
ctf_dict_open_cached (ctf_archive_t *arc, const char *name, int *errp)
|
ctf_dict_open_cached (ctf_archive_t *arc, const char *name, int *errp)
|
||||||
{
|
{
|
||||||
ctf_dict_t *fp;
|
ctf_dict_t *fp;
|
||||||
char *dupname;
|
char *dupname = NULL;
|
||||||
|
|
||||||
/* Just return from the cache if possible. */
|
/* Just return from the cache if possible. */
|
||||||
if (arc->ctfi_dicts
|
if (arc->ctfi_dicts
|
||||||
@@ -728,10 +728,10 @@ ctf_dict_open_cached (ctf_archive_t *arc, const char *name, int *errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Not yet cached: open it. */
|
/* Not yet cached: open it. */
|
||||||
fp = ctf_dict_open (arc, name, errp);
|
if ((fp = ctf_dict_open (arc, name, errp)) == NULL)
|
||||||
dupname = strdup (name);
|
goto err;
|
||||||
|
|
||||||
if (!fp || !dupname)
|
if ((dupname = strdup (name)) == NULL)
|
||||||
goto oom;
|
goto oom;
|
||||||
|
|
||||||
if (arc->ctfi_dicts == NULL)
|
if (arc->ctfi_dicts == NULL)
|
||||||
@@ -762,10 +762,11 @@ ctf_dict_open_cached (ctf_archive_t *arc, const char *name, int *errp)
|
|||||||
return fp;
|
return fp;
|
||||||
|
|
||||||
oom:
|
oom:
|
||||||
ctf_dict_close (fp);
|
|
||||||
free (dupname);
|
|
||||||
if (errp)
|
if (errp)
|
||||||
*errp = ENOMEM;
|
*errp = ENOMEM;
|
||||||
|
err:
|
||||||
|
ctf_dict_close (fp);
|
||||||
|
free (dupname);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user