From 406461adb2759a57db3955d227e4046a3e5cb129 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 1 Jun 2006 05:50:27 +0000 Subject: [PATCH] * bc-data.c (yasm_bc_create_data): Fix crash on empty string (e.g. db ''). svn path=/trunk/yasm/; revision=1547 --- libyasm/bc-data.c | 2 +- libyasm/tests/Makefile.inc | 3 +++ libyasm/tests/emptydata.asm | 1 + libyasm/tests/emptydata.errwarn | 0 libyasm/tests/emptydata.hex | 0 5 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 libyasm/tests/emptydata.asm create mode 100644 libyasm/tests/emptydata.errwarn create mode 100644 libyasm/tests/emptydata.hex diff --git a/libyasm/bc-data.c b/libyasm/bc-data.c index a253534d..9c9dd822 100644 --- a/libyasm/bc-data.c +++ b/libyasm/bc-data.c @@ -271,7 +271,7 @@ yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size, dv = STAILQ_FIRST(datahead); dvo = STAILQ_FIRST(&data->datahead); len = 0; - while (dv) { + while (dv && dvo) { switch (dv->type) { case DV_EMPTY: break; diff --git a/libyasm/tests/Makefile.inc b/libyasm/tests/Makefile.inc index 83016245..0b0a68fb 100644 --- a/libyasm/tests/Makefile.inc +++ b/libyasm/tests/Makefile.inc @@ -15,6 +15,9 @@ EXTRA_DIST += libyasm/tests/charconst64.errwarn EXTRA_DIST += libyasm/tests/charconst64.hex EXTRA_DIST += libyasm/tests/duplabel-err.asm EXTRA_DIST += libyasm/tests/duplabel-err.errwarn +EXTRA_DIST += libyasm/tests/emptydata.asm +EXTRA_DIST += libyasm/tests/emptydata.errwarn +EXTRA_DIST += libyasm/tests/emptydata.hex EXTRA_DIST += libyasm/tests/expr-wide-ident.asm EXTRA_DIST += libyasm/tests/expr-wide-ident.errwarn EXTRA_DIST += libyasm/tests/expr-wide-ident.hex diff --git a/libyasm/tests/emptydata.asm b/libyasm/tests/emptydata.asm new file mode 100644 index 00000000..27b56511 --- /dev/null +++ b/libyasm/tests/emptydata.asm @@ -0,0 +1 @@ +db '' diff --git a/libyasm/tests/emptydata.errwarn b/libyasm/tests/emptydata.errwarn new file mode 100644 index 00000000..e69de29b diff --git a/libyasm/tests/emptydata.hex b/libyasm/tests/emptydata.hex new file mode 100644 index 00000000..e69de29b -- 2.50.1