From c11d77116d58578ea52757381241f34b443a2e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matth=C3=A4us=20Wininger?= Date: Sun, 12 Nov 2023 19:43:57 +0100 Subject: [PATCH 1/2] Fix memory leaks caused by `formatStatContent` --- src/zps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zps.c b/src/zps.c index 50e6fcd..7acaf8c 100644 --- a/src/zps.c +++ b/src/zps.c @@ -187,9 +187,10 @@ static int formatStatContent(char *statContent) { } /* Update the original file content and deallocate the memory. */ strcpy(statContent, contentDup); - free(contentDup); } + free(contentDup); } + regfree(®ex); return EXIT_SUCCESS; } From cb619439a9e297c184fb27114675e7ffe1c90cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matth=C3=A4us=20Wininger?= Date: Sun, 12 Nov 2023 19:46:26 +0100 Subject: [PATCH 2/2] Add `#include` guards to prevent double inclusion --- src/zps.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/zps.h b/src/zps.h index 5650753..30e9a65 100644 --- a/src/zps.h +++ b/src/zps.h @@ -15,6 +15,9 @@ * along with this program. If not, see . */ +#ifndef ZPS_H +#define ZPS_H + #define VERSION "1.2.8" /* Version */ #define _XOPEN_SOURCE 700 /* POSIX.1-2008 + XSI (SuSv4) */ #define _LARGEFILE64_SOURCE /* Enable LFS */ @@ -32,3 +35,5 @@ #define CLR_DEFAULT "\x1b[0m" /* Default color and style attributes */ #define CLR_BOLD "\x1b[1m" /* Bold attribute */ #define CLR_RED "\x1b[31m" /* Color red */ + +#endif // ZPS_H