From: Lukas Krickl Date: Wed, 20 Dec 2023 18:07:51 +0000 (+0100) Subject: Added test case for crashing macro in prod X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=658bf1c00cd3b2dbe98f45321996562202adcf8a;p=ulas%2F.git Added test case for crashing macro in prod --- diff --git a/src/test.c b/src/test.c index 6a19d54..d8aa423 100644 --- a/src/test.c +++ b/src/test.c @@ -122,6 +122,13 @@ void test_preproc(void) { "#macro test\nnested macro $1\n#macro " "nested\ncontent $1\n#endmacro\nafter\nnested n1\n#endmacro\ntest t1"); + // this macro caused a heap buffer overflow in production code + assert_preproc("ld a, verylongmacroinput & 0xFF\nld [hl+], a\nld a, " + "(verylongmacroinput >> 8) & 0xFF\nld [hl+], a\n", + 0, + "#macro testlonginput\nld a, $1 & 0xFF\nld [hl+], a\nld a, " + "($1 >> 8) & 0xFF\nld [hl+], a\n#endmacro\ntestlonginput verylongmacroinput"); + // ifdef assert_preproc( "before\nifdeftest defined!\nafter", 0,