Skip to contentSkip to conversation

nconfig: Fix segfault when menu is empty

PATCH In review Andrej Gelenberg 2 participants 2 messages Aug 2, 2010 – Aug 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nconfig: Fix segfault when menu is empty

Hi,

there is a small bug in nconf, which cause segfault in empty menus (press right arrow in empty menu). Patch is attached.

Regards,
Andrej Gelenberg

From 60265c2f3db2616d3dc493785a47a301f73419bd Mon Sep 17 00:00:00 2001
From: Andrej Gelenberg <[email protected]>
Date: Mon, 2 Aug 2010 11:41:36 +0200
Subject: [PATCH] nconfig: Fix segfault when menu is empty

nconf crush with segfault if press right arrow in empty menu.

---
 scripts/kconfig/nconf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
scripts/kconfig/nconf.c +1 -0
index 762caf8..3db3ca6 100644
@@ -676,6 +676,7 @@ static void *item_data(void)
 	struct mitem *mcur;
 
 	cur = current_item(curses_menu);
+	if ( ! cur ) return NULL;
 	mcur = (struct mitem *) item_userptr(cur);
 	return mcur->usrptr;
 
Signature · 1 line
1.7.2.1
#1 lore raw
Quoted 23 lines · Andrej Gelenberg

there is a small bug in nconf, which cause segfault in empty menus (press right arrow in empty menu). Patch is attached.

Regards,
Andrej Gelenberg

From 60265c2f3db2616d3dc493785a47a301f73419bd Mon Sep 17 00:00:00 2001
From: Andrej Gelenberg <[email protected]>
Date: Mon, 2 Aug 2010 11:41:36 +0200
Subject: [PATCH] nconfig: Fix segfault when menu is empty

nconf crush with segfault if press right arrow in empty menu.

---
 scripts/kconfig/nconf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
scripts/kconfig/nconf.c +0 -0
index 762caf8..3db3ca6 100644

scripts/kconfig/nconf.c static void *item_data(void) · line 681

Quoted 6 lines
scripts/kconfig/nconf.c +1 -0
@@ -676,6 +676,7 @@ static void *item_data(void)
 	struct mitem *mcur;
 
 	cur = current_item(curses_menu);
+	if ( ! cur ) return NULL;
 	mcur = (struct mitem *) item_userptr(cur);
 	return mcur->usrptr;

Applied after fixing indentation (see Documentation/CodingStyle).

Michal