diff --git a/libyasm/section.c b/libyasm/section.c index 592f5b86..1459eccc 100644 --- a/libyasm/section.c +++ b/libyasm/section.c @@ -629,6 +629,10 @@ yasm_bytecode * yasm_section_bcs_append(yasm_section *sect, yasm_bytecode *bc) { if (bc) { + if (!sect) { + yasm_error_set(YASM_ERROR_VALUE, "Attempt to append bytecode to a NULL section or with a NULL bytecode"); + return NULL; + } if (bc->callback) { bc->section = sect; /* record parent section */ STAILQ_INSERT_TAIL(§->bcs, bc, link);