[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Incorrect allocation error handling
From: |
Thomas Dickey |
Subject: |
Re: Incorrect allocation error handling |
Date: |
Sat, 18 Jan 2025 16:35:34 -0500 |
On Mon, Jan 13, 2025 at 08:47:08PM +0000, Shen, Mingjie wrote:
> Hello ncurses maintainers,
>
> In ncurses/c++/cursesf.h, the error handling for new NCursesFormField() is
> incorrect because new throws a std::bad_alloc exception if it fails to
> allocate memory, instead of returning nullptr. To properly handle allocation
> failure, the function should use a try-catch block to catch std::bad_alloc.
thanks - I see this, will probably address it next week, due to the large
number of changes from Branden
> Here are the code snippets of the bugs:
> inline NCursesFormField* dup(int first_row, int first_col)
> {
> NCursesFormField* f = new NCursesFormField();
> if (!f)
> OnError(E_SYSTEM_ERROR);
> and
> inline NCursesFormField* link(int first_row, int first_col) {
> NCursesFormField* f = new NCursesFormField();
> if (!f)
> OnError(E_SYSTEM_ERROR);
>
> Best regards,
> Mingjie
--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
signature.asc
Description: PGP signature