]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- fix segfault in whiptail when no entry is selected in radiolist (debian bug #427590)
authormlichvar <mlichvar>
Mon, 25 Jun 2007 10:37:18 +0000 (10:37 +0000)
committermlichvar <mlichvar>
Mon, 25 Jun 2007 10:37:18 +0000 (10:37 +0000)
dialogboxes.c
newt.spec
whiptail.c

index aa7833db8539264b3c2cd03970c07b732a9e2f48..2664157d183dad59f94033b439aad61d5fd1cfeb 100644 (file)
@@ -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 {
index 2c12187114798639e743a80ce0866b68221af95e..d987be34e94939e61033b52d76e0ea42d665657c 100644 (file)
--- 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 <mlichvar@redhat.com> - 0.52.7-1
 - add support to snack for multiple selection and border in listbox
   and cursorAtEnd in entry (patch by Shawn Starr)
index c5db37d4cb34161994a8a83691565c0d80668502..135a5a7b1a405b1f3f3206cfe787a061d0decf3e 100644 (file)
@@ -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;