From: Peter Johnson Date: Thu, 1 Jun 2006 05:50:27 +0000 (-0000) Subject: * bc-data.c (yasm_bc_create_data): Fix crash on empty string (e.g. db ''). X-Git-Tag: v0.5.0~6^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=406461adb2759a57db3955d227e4046a3e5cb129;p=yasm * bc-data.c (yasm_bc_create_data): Fix crash on empty string (e.g. db ''). svn path=/trunk/yasm/; revision=1547 --- 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