Fixed a potential crash

This commit is contained in:
Pierre Pronchery 2012-09-22 00:27:16 +00:00
parent 2d6cae4e8e
commit f78c504f66

View File

@ -456,8 +456,8 @@ int arch_decode(AsmArch * arch, AsmCode * code, off_t base,
AsmArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
int ret = 0; int ret = 0;
AsmArchInstructionCall * c = *calls; AsmArchInstructionCall * c;
size_t c_cnt = *calls_cnt; size_t c_cnt;
AsmArchInstructionCall * p; AsmArchInstructionCall * p;
size_t offset = 0; size_t offset = 0;
@ -467,6 +467,12 @@ int arch_decode(AsmArch * arch, AsmCode * code, off_t base,
if(arch->plugin->decode == NULL) if(arch->plugin->decode == NULL)
return -error_set_code(1, "%s: %s", arch->plugin->name, return -error_set_code(1, "%s: %s", arch->plugin->name,
"Disassembly not supported"); "Disassembly not supported");
/* check the arguments */
if(calls == NULL || calls_cnt == NULL)
return -error_set_code(1, "%s: %s", arch->plugin->name,
strerror(EINVAL));
c = *calls;
c_cnt = *calls_cnt;
arch->code = code; arch->code = code;
for(;;) for(;;)
{ {