[PATCH 1/3] lpd: Validate get_indicator_for_loc_code() return value
Vasant Hegde <[email protected]> Mon, 21 Nov 2016 15:10:25 +0530
| Newsgroups | gmane.linux.tools.diag.devel |
|---|---|
| Message-ID | <[email protected]> |
Just to be on safer side, validate get_indicator_for_loc_code() return value. Signed-off-by: Vasant Hegde <[email protected]> --- lpd/lp_diag.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lpd/lp_diag.c b/lpd/lp_diag.c index cce8e87..c80f302 100644 --- a/lpd/lp_diag.c +++ b/lpd/lp_diag.c @@ -758,6 +758,14 @@ UI_commit(WINDOW *my_menu_win, MENU *my_menu, if (!strcmp(desc, "loc")) { name = (char *)item_name(items[i]); loc = get_indicator_for_loc_code(ident_list, name); + if (!loc) { + if (cur_state[i] == '+') { + cur_state[i] = prev_state[i]; + err = 1; + } + continue; + } + rc = get_indicator_state(LED_TYPE_IDENT, loc, &ident); if (rc) { if (cur_state[i] == '+') { ------------------------------------------------------------------------------