From 496702e3c2486adae863fd919f20e7a7490c847c Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Fri, 18 Dec 2020 07:52:38 +0100 Subject: [PATCH] dxf2dwg: fix leak on wrong file eg. programs/dxf2dwg -y -v3 example_2000.dwg ERROR: This is a DWG, not a DXF file: ../td/example_2000.dwg READ ERROR 0x800 ../td/example_2000.dwg ================================================================= ==1678362==ERROR: LeakSanitizer: detected memory leaks Direct leak of 21 byte(s) in 1 object(s) allocated from: #0 0x7f55fa6e7667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667) #1 0x402eba in suffix ../../programs/suffix.inc:53 #2 0x4043d7 in main ../../programs/dxf2dwg.c:299 --- programs/dxf2dwg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/programs/dxf2dwg.c b/programs/dxf2dwg.c index 04448ed906..faf9be2c74 100644 --- a/programs/dxf2dwg.c +++ b/programs/dxf2dwg.c @@ -314,6 +314,8 @@ main (int argc, char *argv[]) if (error >= DWG_ERR_CRITICAL) { fprintf (stderr, "READ ERROR 0x%x %s\n", error, filename_in); + if (need_free) + free (filename_out); continue; }