[vte] lib: Abort when alloc returns nullptr
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] lib: Abort when alloc returns nullptr
- Date: Wed, 30 Sep 2020 14:52:37 +0000 (UTC)
commit 71c03eaa260156a84884643ccbb6861c8fa558a1
Author: Christian Persch <chpe src gnome org>
Date: Wed Sep 30 16:52:31 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.
src/vtegtk.cc | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index bde7f976..483cb665 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -5728,6 +5728,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 (...) {
@@ -5761,6 +5763,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]