[vte/vte-0-62] lib: Abort when alloc returns nullptr



commit e20e189a735591f956acef7e4dcc86bc03c7bccb
Author: Christian Persch <chpe src gnome org>
Date:   Wed Sep 30 16:53:02 2020 +0200

    lib: Abort when alloc returns nullptr
    
    Allocating memory with glib (g_new, etc) will abort the process
    when memory allocation fails. Do the same when using the C++
    allocator (operator new, etc) throws bad_alloc.
    
    (cherry picked from commit 71c03eaa260156a84884643ccbb6861c8fa558a1)

 src/vtegtk.cc | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 66456cec..a0f7cf81 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -5687,6 +5687,8 @@ try
 
         try {
                 throw; // rethrow current exception
+        } catch (std::bad_alloc const& e) {
+                g_error("Allocation failure: %s\n", e.what());
         } catch (std::exception const& e) {
                 exception_append_to_string(e, what);
         } catch (...) {
@@ -5720,6 +5722,8 @@ try
 
         try {
                 throw; // rethrow current exception
+        } catch (std::bad_alloc const& e) {
+                g_error("Allocation failure: %s\n", e.what());
         } catch (std::exception const& e) {
                 exception_append_to_string(e, what);
         } catch (...) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]