From 2931ecb08afcb99d8e6ab032f9406891b0a6fb7c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 10 Sep 2006 19:44:18 +0000 Subject: [PATCH] Fix invalid memory access on macro with multiple of 16 arguments. Patch by: Mathieu Monnier svn path=/trunk/yasm/; revision=1611 --- modules/preprocs/nasm/nasm-pp.c | 2 +- modules/preprocs/nasm/tests/16args.asm | 27 ++++++ modules/preprocs/nasm/tests/16args.errwarn | 0 modules/preprocs/nasm/tests/16args.hex | 96 ++++++++++++++++++++++ modules/preprocs/nasm/tests/Makefile.inc | 3 + 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 modules/preprocs/nasm/tests/16args.asm create mode 100644 modules/preprocs/nasm/tests/16args.errwarn create mode 100644 modules/preprocs/nasm/tests/16args.hex diff --git a/modules/preprocs/nasm/nasm-pp.c b/modules/preprocs/nasm/nasm-pp.c index 823b4bc2..97d49ce3 100644 --- a/modules/preprocs/nasm/nasm-pp.c +++ b/modules/preprocs/nasm/nasm-pp.c @@ -1376,7 +1376,7 @@ count_mmac_params(Token * t, int *nparam, Token *** params) *params = NULL; while (t) { - if (*nparam >= paramsize) + if (*nparam+1 >= paramsize) { paramsize += PARAM_DELTA; *params = nasm_realloc(*params, sizeof(**params) * paramsize); diff --git a/modules/preprocs/nasm/tests/16args.asm b/modules/preprocs/nasm/tests/16args.asm new file mode 100644 index 00000000..506db96c --- /dev/null +++ b/modules/preprocs/nasm/tests/16args.asm @@ -0,0 +1,27 @@ +%define BLA16 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 + +%macro SUPERBLA16 16 +mov eax, %1 +mov eax, %2 +mov eax, %3 +mov eax, %4 +mov eax, %5 +mov eax, %6 +mov eax, %7 +mov eax, %8 +mov eax, %9 +mov eax, %10 +mov eax, %11 +mov eax, %12 +mov eax, %13 +mov eax, %14 +mov eax, %15 +mov eax, %16 +%endmacro + +SECTION .text + +yoyo: + +SUPERBLA16 BLA16 + diff --git a/modules/preprocs/nasm/tests/16args.errwarn b/modules/preprocs/nasm/tests/16args.errwarn new file mode 100644 index 00000000..e69de29b diff --git a/modules/preprocs/nasm/tests/16args.hex b/modules/preprocs/nasm/tests/16args.hex new file mode 100644 index 00000000..2eaa59dd --- /dev/null +++ b/modules/preprocs/nasm/tests/16args.hex @@ -0,0 +1,96 @@ +66 +b8 +01 +00 +00 +00 +66 +b8 +02 +00 +00 +00 +66 +b8 +03 +00 +00 +00 +66 +b8 +04 +00 +00 +00 +66 +b8 +05 +00 +00 +00 +66 +b8 +06 +00 +00 +00 +66 +b8 +07 +00 +00 +00 +66 +b8 +08 +00 +00 +00 +66 +b8 +09 +00 +00 +00 +66 +b8 +0a +00 +00 +00 +66 +b8 +0b +00 +00 +00 +66 +b8 +0c +00 +00 +00 +66 +b8 +0d +00 +00 +00 +66 +b8 +0e +00 +00 +00 +66 +b8 +0f +00 +00 +00 +66 +b8 +10 +00 +00 +00 diff --git a/modules/preprocs/nasm/tests/Makefile.inc b/modules/preprocs/nasm/tests/Makefile.inc index 2dd9d02d..54faa00f 100644 --- a/modules/preprocs/nasm/tests/Makefile.inc +++ b/modules/preprocs/nasm/tests/Makefile.inc @@ -3,6 +3,9 @@ TESTS += modules/preprocs/nasm/tests/nasmpp_test.sh EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp_test.sh +EXTRA_DIST += modules/preprocs/nasm/tests/16args.asm +EXTRA_DIST += modules/preprocs/nasm/tests/16args.errwarn +EXTRA_DIST += modules/preprocs/nasm/tests/16args.hex EXTRA_DIST += modules/preprocs/nasm/tests/ifcritical-err.asm EXTRA_DIST += modules/preprocs/nasm/tests/ifcritical-err.errwarn EXTRA_DIST += modules/preprocs/nasm/tests/longline.asm -- 2.40.0