From: mlichvar Date: Mon, 25 Jun 2007 10:37:18 +0000 (+0000) Subject: - fix segfault in whiptail when no entry is selected in radiolist (debian bug #427590) X-Git-Tag: r0-52-8~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5dd92b24d4ab2ef71eaff8ef43b1f40deb1ccd08;p=thirdparty%2Fnewt.git - fix segfault in whiptail when no entry is selected in radiolist (debian bug #427590) --- diff --git a/dialogboxes.c b/dialogboxes.c index aa7833d..2664157 100644 --- a/dialogboxes.c +++ b/dialogboxes.c @@ -463,12 +463,13 @@ int checkList(const char * text, int height, int width, poptContext optCon, if (useRadio) { answer = newtRadioGetCurrent(cbInfo[0].comp); + *selections = malloc(sizeof(char *) * 2); + if (*selections == NULL) + return DLG_ERROR; + (*selections)[0] = (*selections)[1] = NULL; for (i = 0; i < numBoxes; i++) if (cbInfo[i].comp == answer) { - *selections = malloc(sizeof(char *) * 2); - if (*selections == NULL) return DLG_ERROR; (*selections)[0] = cbInfo[i].tag; - (*selections)[1] = NULL; break; } } else { diff --git a/newt.spec b/newt.spec index 2c12187..d987be3 100644 --- a/newt.spec +++ b/newt.spec @@ -88,6 +88,8 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libnewt.a %changelog +- fix segfault in whiptail when no entry is selected in radiolist + * Fri Jun 15 2007 Miroslav Lichvar - 0.52.7-1 - add support to snack for multiple selection and border in listbox and cursorAtEnd in entry (patch by Shawn Starr) diff --git a/whiptail.c b/whiptail.c index c5db37d..135a5a7 100644 --- a/whiptail.c +++ b/whiptail.c @@ -569,7 +569,8 @@ int main(int argc, const char ** argv) { case MODE_RADIOLIST: rc = checkList(text, height, width, optCon, 1, flags, &selections); if (rc == DLG_OKAY) { - fprintf(output, "%s", selections[0]); + if (selections[0]) + fprintf(output, "%s", selections[0]); free(selections); } break;