From: Robert Pengelly Date: Sun, 1 Mar 2026 11:04:10 +0000 (+0000) Subject: Fied memory leaks X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=955026eafd3d84bd7c0ce5e47dfec8940f643ad2;p=unxz.git Fied memory leaks --- diff --git a/include/xz.h b/include/xz.h index 7e1ccd4..11c7a36 100755 --- a/include/xz.h +++ b/include/xz.h @@ -241,4 +241,4 @@ extern void xz_crc64_init (void); */ extern uint64_t xz_crc64 (const uint8_t *buf, uint64_t size, uint64_t crc); -#endif /* _XZ_H */ \ No newline at end of file +#endif /* _XZ_H */ diff --git a/libxz/xz_dec_lzma2.c b/libxz/xz_dec_lzma2.c index 1f2deb4..a4dd2e7 100755 --- a/libxz/xz_dec_lzma2.c +++ b/libxz/xz_dec_lzma2.c @@ -341,7 +341,7 @@ struct xz_dec_lzma2 { * Reset the dictionary state. When in single-call mode, set up the beginning * of the dictionary to point to the actual output buffer. */ -static void dict_reset(struct dictionary *dict, struct xz_buf *b) { +static void dict_reset (struct dictionary *dict, struct xz_buf *b) { if (DEC_IS_SINGLE (dict->mode)) { diff --git a/report.c b/report.c index 8e128ef..b30b515 100755 --- a/report.c +++ b/report.c @@ -17,7 +17,11 @@ static int OriginalConsoleColor = -1; static void reset_console_color (void) { -#if defined (_WIN32) +#if defined (unix) || defined (__unix) || defined (__unix__) || defined (__APPLE__) + + fprintf (stderr, "\033[0m"); + +#elif defined (_WIN32) HANDLE hStdError = GetStdHandle (STD_ERROR_HANDLE); @@ -26,17 +30,17 @@ static void reset_console_color (void) { SetConsoleTextAttribute (hStdError, OriginalConsoleColor); OriginalConsoleColor = -1; -#else - - fprintf (stderr, "\033[0m"); - #endif } static void set_console_color (int color) { -#if defined (_WIN32) +#if defined (unix) || defined (__unix) || defined (__unix__) || defined (__APPLE__) + + fprintf (stderr, "\033[%dm", color); + +#elif defined (_WIN32) HANDLE hStdError = GetStdHandle (STD_ERROR_HANDLE); WORD wColor; @@ -56,10 +60,6 @@ static void set_console_color (int color) { wColor = (OriginalConsoleColor & 0xF0) + (color & 0xF); SetConsoleTextAttribute (hStdError, wColor); -#else - - fprintf (stderr, "\033[%dm", color); - #endif } diff --git a/unxz.c b/unxz.c index db980d8..86e6f53 100755 --- a/unxz.c +++ b/unxz.c @@ -78,6 +78,8 @@ int main (int argc, char **argv) { if (!(ifp = fopen (ipath, "r+b"))) { report_at (program_name, 0, REPORT_ERROR, "failed to open '%s' for reading", ipath); + + xz_dec_end (s); continue; } @@ -88,7 +90,9 @@ int main (int argc, char **argv) { report_at (program_name, 0, REPORT_ERROR, "skipping %s", ipath); + xz_dec_end (s); fclose (ifp); + continue; } @@ -102,7 +106,9 @@ int main (int argc, char **argv) { report_at (program_name, 0, REPORT_ERROR, "failed to open '%s' for writing", opath); free (opath); + xz_dec_end (s); fclose (ifp); + continue; }