No longer potentially crash format plug-ins while guessing architectures
This commit is contained in:
parent
ff9acd73d1
commit
92b3cd7eb5
11
src/format.c
11
src/format.c
@ -168,7 +168,7 @@ int format_exit(Format * format)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
if(format->plugin->exit != NULL)
|
if(format->plugin->helper != NULL && format->plugin->exit != NULL)
|
||||||
ret = format->plugin->exit(format->plugin);
|
ret = format->plugin->exit(format->plugin);
|
||||||
format->plugin->helper = NULL;
|
format->plugin->helper = NULL;
|
||||||
format->fp = NULL;
|
format->fp = NULL;
|
||||||
@ -190,6 +190,8 @@ int format_function(Format * format, char const * function)
|
|||||||
int format_init(Format * format, char const * arch, char const * filename,
|
int format_init(Format * format, char const * arch, char const * filename,
|
||||||
FILE * fp)
|
FILE * fp)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(\"%s\", %p)\n", __func__, filename,
|
fprintf(stderr, "DEBUG: %s(\"%s\", %p)\n", __func__, filename,
|
||||||
(void *)fp);
|
(void *)fp);
|
||||||
@ -199,9 +201,10 @@ int format_init(Format * format, char const * arch, char const * filename,
|
|||||||
format->filename = filename;
|
format->filename = filename;
|
||||||
format->fp = fp;
|
format->fp = fp;
|
||||||
format->plugin->helper = &format->helper;
|
format->plugin->helper = &format->helper;
|
||||||
if(format->plugin->init != NULL)
|
if(format->plugin->init != NULL && (ret = format->plugin->init(
|
||||||
return format->plugin->init(format->plugin, arch);
|
format->plugin, arch)) != 0)
|
||||||
return 0;
|
format->plugin->helper = NULL;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user