|
From: | Shen, Mingjie |
Subject: | Incorrect allocation error handling |
Date: | Mon, 13 Jan 2025 20:47:08 +0000 |
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. 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 |
[Prev in Thread] | Current Thread | [Next in Thread] |