From 8dcebc96299149845d63e23f27c75a1ecc0b3538 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 27 May 2022 00:24:12 +0000 Subject: [PATCH] Handle allocation errors when creating menu items on Haiku * src/haiku_support.cc (class EmacsMenuItem): Don't abort on failed strdup. --- src/haiku_support.cc | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 977728b5e3b..c1617c86cc7 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2385,30 +2385,25 @@ public: class EmacsMenuItem : public BMenuItem { public: - int menu_bar_id = -1; - void *menu_ptr = NULL; - void *wind_ptr = NULL; - char *key = NULL; - char *help = NULL; - - EmacsMenuItem (const char *ky, - const char *str, - const char *help, - BMessage *message = NULL) : BMenuItem (str, message) + int menu_bar_id; + void *menu_ptr; + void *wind_ptr; + char *key; + char *help; + + EmacsMenuItem (const char *key_label, const char *label, + const char *help, BMessage *message = NULL) + : BMenuItem (label, message), + menu_bar_id (-1), + menu_ptr (NULL), + wind_ptr (NULL), + key (NULL), + help (NULL) { - if (ky) - { - key = strdup (ky); - if (!key) - gui_abort ("strdup failed"); - } + if (key_label) + key = strdup (key_label); - if (help) - { - this->help = strdup (help); - if (!this->help) - gui_abort ("strdup failed"); - } + this->help = strdup (help); } ~EmacsMenuItem () -- 2.39.2