From d980aba29d84174f17ed18394854513fb5781a9c Mon Sep 17 00:00:00 2001 From: "maosheng.wei" Date: Thu, 6 Jul 2023 17:03:18 +0800 Subject: [PATCH] FIX: [STUDIO-3531] Differentiation of Memory Exhaustion Change-Id: I009b78f1f3d4339745e44208f10b91083efaf744 --- src/BambuStudio.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index db099d1aa..dd4119313 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -3815,8 +3815,15 @@ extern "C" { SET_DEFULTER_HANDLER(); #endif std::set_new_handler([]() { - int *a = nullptr; - *a = 0; + int smallSize = 10 * 1024 * 1024; + int *test_apply = (int *) malloc(smallSize); + if (test_apply == NULL) { + throw std::bad_alloc(); + } else { + free(test_apply); + int *a = nullptr; + *a = 0; + } }); // Call the UTF8 main. return CLI().run(argc, argv_ptrs.data());