From e864c1aaac0bed995ce50b071c43a8ca3c4e900a Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 2 Feb 2024 23:22:25 +0100 Subject: [PATCH] fix: Crash due to libmagic bug when using `MAGIC_COMPRESS` with `magic_buffer` #1529 --- lib/libimhex/source/helpers/magic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/source/helpers/magic.cpp b/lib/libimhex/source/helpers/magic.cpp index 51bf139f1..48c2fc84f 100644 --- a/lib/libimhex/source/helpers/magic.cpp +++ b/lib/libimhex/source/helpers/magic.cpp @@ -101,7 +101,7 @@ namespace hex::magic { auto magicFiles = getMagicFiles(); if (magicFiles.has_value()) { - magic_t ctx = magic_open(MAGIC_COMPRESS | (firstEntryOnly ? MAGIC_NONE : MAGIC_CONTINUE)); + magic_t ctx = magic_open(firstEntryOnly ? MAGIC_NONE : MAGIC_CONTINUE); ON_SCOPE_EXIT { magic_close(ctx); }; if (magic_load(ctx, magicFiles->c_str()) == 0) { @@ -126,7 +126,7 @@ namespace hex::magic { auto magicFiles = getMagicFiles(); if (magicFiles.has_value()) { - magic_t ctx = magic_open(MAGIC_COMPRESS | MAGIC_MIME_TYPE | (firstEntryOnly ? MAGIC_NONE : MAGIC_CONTINUE)); + magic_t ctx = magic_open(MAGIC_MIME_TYPE | (firstEntryOnly ? MAGIC_NONE : MAGIC_CONTINUE)); ON_SCOPE_EXIT { magic_close(ctx); }; if (magic_load(ctx, magicFiles->c_str()) == 0) {