diff --git a/autotests/plugins/cliunarchiverplugin/CMakeLists.txt b/autotests/plugins/cliunarchiverplugin/CMakeLists.txt --- a/autotests/plugins/cliunarchiverplugin/CMakeLists.txt +++ b/autotests/plugins/cliunarchiverplugin/CMakeLists.txt @@ -12,3 +12,6 @@ LINK_LIBRARIES testhelper kerfuffle Qt5::Test TEST_NAME cliunarchivertest NAME_PREFIX plugins-) + +# cliunarchiver plugin needs exceptions enabled +kde_target_enable_exceptions(cliunarchivertest PRIVATE) diff --git a/plugins/cliunarchiverplugin/CMakeLists.txt b/plugins/cliunarchiverplugin/CMakeLists.txt --- a/plugins/cliunarchiverplugin/CMakeLists.txt +++ b/plugins/cliunarchiverplugin/CMakeLists.txt @@ -22,6 +22,9 @@ kerfuffle_add_plugin(kerfuffle_cliunarchiver ${kerfuffle_cliunarchiver_SRCS}) +# This plugin has a catch() block +kde_target_enable_exceptions(kerfuffle_cliunarchiver PRIVATE) + set(SUPPORTED_ARK_MIMETYPES "${SUPPORTED_ARK_MIMETYPES}${SUPPORTED_CLIUNARCHIVER_MIMETYPES}" PARENT_SCOPE) set(INSTALLED_KERFUFFLE_PLUGINS "${INSTALLED_KERFUFFLE_PLUGINS}kerfuffle_cliunarchiver;" PARENT_SCOPE) diff --git a/plugins/cliunarchiverplugin/cliplugin.cpp b/plugins/cliunarchiverplugin/cliplugin.cpp --- a/plugins/cliunarchiverplugin/cliplugin.cpp +++ b/plugins/cliunarchiverplugin/cliplugin.cpp @@ -138,7 +138,15 @@ { // Collect the json output line by line. if (m_operationMode == List) { - m_jsonOutput += line + QLatin1Char('\n'); + // #372210: lsar can generate huge JSONs for big archives. + // We can at least catch a bad_alloc here in order to not crash. + try { + m_jsonOutput += line + QLatin1Char('\n'); + } catch (const std::bad_alloc&) { + m_jsonOutput.clear(); + emit error(i18n("Not enough memory for loading the archive.")); + return false; + } } if (m_operationMode == List) {