From 583dc7ddd934997a9670b606a9a87aa52ae68b8f Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 23 Jul 2019 07:35:01 +0000 Subject: [PATCH] Core: Detection of non-standard exit (supressing leaks detection) git-svn-id: svn://ultimatepp.org/upp/trunk@13509 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/App.cpp | 3 +++ uppsrc/Core/heapdbg.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/uppsrc/Core/App.cpp b/uppsrc/Core/App.cpp index a05d3cb68..7875a18a6 100644 --- a/uppsrc/Core/App.cpp +++ b/uppsrc/Core/App.cpp @@ -337,6 +337,8 @@ void Exit(int code) throw ExitExc(); } +bool AppNormalExit; + void AppExecute__(void (*app)()) { try { @@ -345,6 +347,7 @@ void AppExecute__(void (*app)()) catch(ExitExc) { return; } + AppNormalExit = true; } #ifdef PLATFORM_POSIX diff --git a/uppsrc/Core/heapdbg.cpp b/uppsrc/Core/heapdbg.cpp index f406653a6..a72d0b8b9 100644 --- a/uppsrc/Core/heapdbg.cpp +++ b/uppsrc/Core/heapdbg.cpp @@ -10,6 +10,8 @@ int sMemDiagInitCount; namespace Upp { +extern bool AppNormalExit; + #if defined(UPP_HEAP) #include "HeapImp.h" @@ -192,6 +194,10 @@ void MemoryDumpLeaks() { if(PanicMode) return; + if(!AppNormalExit) { + VppLog() << "Application was terminated in a non-standard way (e.g. exit(x) call or Ctrl+C)\n"; + return; + } #ifndef PLATFORM_POSIX if(s_ignoreleaks) Panic("Ignore leaks Begin/End mismatch!");