From 9fedbd96f433072bdf6d4767148a9e4b2a50d8e2 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 2 May 2020 12:18:18 +0200 Subject: [PATCH] fixed leaks in test cases (#1247) --- samples/sample_x86.c | 1 + samples/sample_x86_32_gdt_and_seg_regs.c | 1 + tests/regress/map_crash.c | 1 + tests/regress/sigill.c | 1 + tests/regress/x86_vex | Bin 0 -> 28104 bytes tests/unit/test_mem_map_ptr.c | 2 ++ 6 files changed, 6 insertions(+) create mode 100755 tests/regress/x86_vex diff --git a/samples/sample_x86.c b/samples/sample_x86.c index 84928911..99d63b02 100644 --- a/samples/sample_x86.c +++ b/samples/sample_x86.c @@ -301,6 +301,7 @@ static void test_i386_map_ptr(void) printf(">>> Failed to read 4 bytes from [0x%x]\n", ADDRESS); uc_close(uc); + free(mem); } static void test_i386_jump(void) diff --git a/samples/sample_x86_32_gdt_and_seg_regs.c b/samples/sample_x86_32_gdt_and_seg_regs.c index 6bfb45b8..e6023f8e 100644 --- a/samples/sample_x86_32_gdt_and_seg_regs.c +++ b/samples/sample_x86_32_gdt_and_seg_regs.c @@ -280,6 +280,7 @@ static void gdt_demo() assert(memcmp(buf, "\x67\x45\x23\x01\xef\xcd\xab\x89", 8) == 0); uc_close(uc); + free(gdt); } /******************************************************************************/ diff --git a/tests/regress/map_crash.c b/tests/regress/map_crash.c index f794b4d7..1d89d8dd 100644 --- a/tests/regress/map_crash.c +++ b/tests/regress/map_crash.c @@ -27,5 +27,6 @@ int main() uc_mem_write (uc, UC_BUG_WRITE_ADDR, buf, size); } uc_close(uc); + free(buf); return 0; } diff --git a/tests/regress/sigill.c b/tests/regress/sigill.c index ea8f987f..9e5061d3 100644 --- a/tests/regress/sigill.c +++ b/tests/regress/sigill.c @@ -41,6 +41,7 @@ int main() uc_hook_add(uc, &uh_trap, UC_HOOK_INTR, _interrupt, NULL, 1, 0); uc_emu_start(uc, UC_BUG_WRITE_ADDR, UC_BUG_WRITE_ADDR+8, 0, 1); uc_close(uc); + free(buf); printf ("Correct: %s\n", got_sigill? "YES": "NO"); return got_sigill? 0: 1; } diff --git a/tests/regress/x86_vex b/tests/regress/x86_vex new file mode 100755 index 0000000000000000000000000000000000000000..348db7fc0aafac414d998464c40e9cf36386a4a1 GIT binary patch literal 28104 zcmeHwdw5jU)%Tf9axx*13>OhpV1R(2CS*c@1Vtx=goy@7At1KuVKQ?j8JWzCbAdqX zD;7~w8jG#1y_fcDty;CbT73~)i?tQCt<_$reQR6v)7MEa7V%QcTg~@dYwtaC<|JeL z$M<}f=ixl$?7h}rd+oK?UVH7!?6bMPt+Tzv;n39M)GpQtI&!wa_+*01lo13ztx2oI zd#*M|(*c(7Hl@x|9iFYETe0R!pdw7ndQ=yWOLdsX{*)>6=s8DkYnDUiT zRKoVKP3BXfO3#(&q0D$Z{LY0(s3Le&Xw65u*;32N+LjfC;SpJhtg4KZi_}5+_R4&F zWj+;lNqwnM>66&d-w$QFJzRw}dQ?cX^mM(F4pH1Uhrv;yqF15H_W|T1Ises1seQdH zub5sANcmMr`ln}6G}5!QaZxl>8;!&=1GNK9OKX=l)}`Wg4P5UjprNK%y>_FPdg4n} zzE6C$ucjn@RZq(sq3S17Pm$at1MwpodWc>Y$8j=wN~e0==-{Lh!YLappLFZw&u)3n zXg;}5p^#emJP2@7A&Q|MFdhs4N)i0mi{SsW2z~`BBAc+F^p}dr^VK5w1>iH5oDUZ% z_h1qH?M3kK6e;)IBJ^h#k>}|me4Z)7XF?IYQG`!R5&GFh@KxaB!Jqx32p!A$kf4FIVfJrf09y_Z5BqW4I8`TS(t%{!Fa&84LSkq{Vv#g5aU7X~TaEre zG#U>Y4GJ4iq$A)MGSg--O^iX4Nts3Hvg-&xBq4<8%`ci6wOe_+NCu4zdlu%wR6NLD^#`a_+Z4!`5C(UFso}_p% z8c#8@-|Wv*#1m#rWlNfY5XFh0KailP*`E7GNlqhLI$J3=Ra0a3mIpMs|{g5Cc&R%8kUd)twzHTaAXg#$2ocR%U%* zmUzTl;N`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