Fix segfault if lev_comp could not alloc memory for opcode
This commit is contained in:
+4
-2
@@ -1294,11 +1294,13 @@ genericptr_t dat;
|
|||||||
lc_error("Unknown opcode '%d'", opc);
|
lc_error("Unknown opcode '%d'", opc);
|
||||||
|
|
||||||
tmp = (_opcode *) alloc(sizeof(_opcode) * (nop + 1));
|
tmp = (_opcode *) alloc(sizeof(_opcode) * (nop + 1));
|
||||||
if (sp->opcodes && nop) {
|
if (sp->opcodes && nop && tmp) {
|
||||||
(void) memcpy(tmp, sp->opcodes, sizeof(_opcode) * nop);
|
(void) memcpy(tmp, sp->opcodes, sizeof(_opcode) * nop);
|
||||||
free(sp->opcodes);
|
free(sp->opcodes);
|
||||||
} else if (!tmp)
|
} else if (!tmp) {
|
||||||
lc_error("Could not alloc opcode space");
|
lc_error("Could not alloc opcode space");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sp->opcodes = tmp;
|
sp->opcodes = tmp;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user