From f072502ad1bfb1b1880e1d3f0a1b8a03b3e038f0 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 12 Oct 2006 03:10:14 +0000 Subject: [PATCH] Fix crash case in data bytecode handling (raw followed by non-raw value). Reported by: Danny Reeves svn path=/trunk/yasm/; revision=1646 --- libyasm/bc-data.c | 2 ++ libyasm/tests/Makefile.inc | 2 ++ libyasm/tests/data-rawvalue.asm | 3 +++ libyasm/tests/data-rawvalue.hex | 13 +++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 libyasm/tests/data-rawvalue.asm create mode 100644 libyasm/tests/data-rawvalue.hex diff --git a/libyasm/bc-data.c b/libyasm/bc-data.c index 5c6f7fca..6e025c53 100644 --- a/libyasm/bc-data.c +++ b/libyasm/bc-data.c @@ -300,6 +300,8 @@ yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size, &dvo->data.raw.contents[len], 1); } else { + if (len > 0) + dvo = STAILQ_NEXT(dvo, link); dvo->type = dv->type; dvo->data.val = dv->data.val; /* structure copy */ dvo->data.val.size = size*8; /* remember size */ diff --git a/libyasm/tests/Makefile.inc b/libyasm/tests/Makefile.inc index f34f651c..d53e3185 100644 --- a/libyasm/tests/Makefile.inc +++ b/libyasm/tests/Makefile.inc @@ -12,6 +12,8 @@ EXTRA_DIST += libyasm/tests/absloop-err.asm EXTRA_DIST += libyasm/tests/absloop-err.errwarn EXTRA_DIST += libyasm/tests/charconst64.asm EXTRA_DIST += libyasm/tests/charconst64.hex +EXTRA_DIST += libyasm/tests/data-rawvalue.asm +EXTRA_DIST += libyasm/tests/data-rawvalue.hex EXTRA_DIST += libyasm/tests/duplabel-err.asm EXTRA_DIST += libyasm/tests/duplabel-err.errwarn EXTRA_DIST += libyasm/tests/emptydata.asm diff --git a/libyasm/tests/data-rawvalue.asm b/libyasm/tests/data-rawvalue.asm new file mode 100644 index 00000000..3ebc7d0c --- /dev/null +++ b/libyasm/tests/data-rawvalue.asm @@ -0,0 +1,3 @@ +x db 0 +dd 0,x,0 + diff --git a/libyasm/tests/data-rawvalue.hex b/libyasm/tests/data-rawvalue.hex new file mode 100644 index 00000000..089b49c8 --- /dev/null +++ b/libyasm/tests/data-rawvalue.hex @@ -0,0 +1,13 @@ +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00