Hi Pavel,
sorry that nobody answered your report in the last 11+ years.
On 1999-02-09 11:17 +0100, Pavel Andreew wrote:
> Package: libncurses4
> Version: 4.2-3
>
> The new_item() function use incorrect initialisation of the ITEM
> structure.
Could you please elaborate why it is incorrect, if you still remember?
> This patch (from ncurses 1.9.9g, menu/m_item_new.c) resolve problem:
>
> ==============================================================================
> diff -ru ncurses-4.2.orig/menu/m_item_new.c ncurses-4.2/menu/m_item_new.c
> --- ncurses-4.2.orig/menu/m_item_new.c Wed Feb 11 17:13:50 1998
> +++ ncurses-4.2/menu/m_item_new.c Tue Feb 9 14:49:16 1999
> @@ -89,13 +89,35 @@
> *item = _nc_Default_Item; /* hope we have struct assignment */
>
> item->name.length = strlen(name);
> - item->name.str = name;
> + item->name.str = (char *)malloc(1 + item->name.length);
> + if (item->name.str)
> + {
> + strcpy(item->name.str, name);
> + }
> + else
> + {
> + free(item);
> + SET_ERROR( E_SYSTEM_ERROR );
> + return (ITEM *)0;
> + }
>
> if (description && (*description != '\0') &&
> Is_Printable_String(description))
> {
> item->description.length = strlen(description);
> - item->description.str = description;
> + item->description.str =
> + (char *)malloc(1 + item->description.length);
> + if (item->description.str)
> + {
> + strcpy(item->description.str, description);
> + }
> + else
> + {
> + free(item->name.str);
> + free(item);
> + SET_ERROR( E_SYSTEM_ERROR );
> + return (ITEM *)0;
> + }
> }
> else
> {
> @@ -128,6 +150,10 @@
> if (item->imenu)
> RETURN( E_CONNECTED );
>
> + if (item->name.str)
> + free(item->name.str);
> + if (item->description.str)
> + free (item->description.str);
> free(item);
>
> RETURN( E_OK );
> =============================================================================
As you may imagine, this patch does not apply cleanly anymore. If you
still care, could you update it to a more recent ncurses version?
Regards,
Sven
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]