diff --git a/Telegram/SourceFiles/core/crash_reports.cpp b/Telegram/SourceFiles/core/crash_reports.cpp index cbea96be25..0c5d401316 100644 --- a/Telegram/SourceFiles/core/crash_reports.cpp +++ b/Telegram/SourceFiles/core/crash_reports.cpp @@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS #ifdef Q_OS_WIN +#include + #pragma warning(push) #pragma warning(disable:4091) #include "client/windows/handler/exception_handler.h" @@ -105,11 +107,20 @@ std::unique_ptr ReservedMemory; void InstallOperatorNewHandler() { ReservedMemory = std::make_unique(); +#ifdef Q_OS_WIN + _set_new_handler([](size_t requested) -> int { + _set_new_handler(nullptr); + ReservedMemory.reset(); + CrashReports::SetAnnotation("Requested", QString::number(requested)); + Unexpected("Could not allocate!"); + }); +#else // Q_OS_WIN std::set_new_handler([] { std::set_new_handler(nullptr); ReservedMemory.reset(); Unexpected("Could not allocate!"); }); +#endif // Q_OS_WIN } void InstallQtMessageHandler() {