more error checks in menuitem.c

option value in ALPHA mode is treated special in menu_commands.c
This commit is contained in:
marschap
2005-03-13 13:17:32 +00:00
parent e29154a03b
commit 846b6fb740
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -348,7 +348,7 @@ menu_set_item_func (Client * c, int argc, char **argv)
{ MENUITEM_NUMERIC, "minvalue", INT, offsetof(MenuItem,data.numeric.minvalue) },
{ MENUITEM_NUMERIC, "maxvalue", INT, offsetof(MenuItem,data.numeric.maxvalue) },
/*{ MENUITEM_NUMERIC, "allow_decimals",BOOLEAN, offsetof(MenuItem,data.numeric.allow_decimals) },*/
{ MENUITEM_ALPHA, "value", STRING, offsetof(MenuItem,data.alpha.value) },
{ MENUITEM_ALPHA, "value", STRING, -1 /*offsetof(MenuItem,data.alpha.value)*/ },
{ MENUITEM_ALPHA, "minlength", SHORT, offsetof(MenuItem,data.alpha.minlength) },
{ MENUITEM_ALPHA, "maxlength", SHORT, offsetof(MenuItem,data.alpha.maxlength) },
{ MENUITEM_ALPHA, "password_char",STRING, -1 },
+4 -2
View File
@@ -258,8 +258,10 @@ MenuItem *menuitem_create_alpha (char *id, MenuEventFunc(*event_func),
new_item->data.alpha.allowed_extra = strdup (allowed_extra);
new_item->data.alpha.value = malloc (maxlength + 1);
strncpy (new_item->data.alpha.value, value, maxlength);
new_item->data.alpha.value[maxlength] = 0;
if (new_item->data.alpha.value != NULL) {
strncpy (new_item->data.alpha.value, value, maxlength);
new_item->data.alpha.value[maxlength] = 0;
}
new_item->data.alpha.edit_str = malloc (maxlength + 1);
}