tools: iio: iio_generic_buffer: initialize channel array pointer
authorAlison Schofield <[email protected]>
Wed, 27 Jul 2016 03:17:43 +0000 (20:17 -0700)
committerJonathan Cameron <[email protected]>
Mon, 15 Aug 2016 16:05:30 +0000 (17:05 +0100)
Uninitialized channel pointer causes segmentation fault when we
call free(channel) during cleanup() with no channels initialized.
This happens when you exit early for usage errors.  Initialize
the pointer to NULL when it is declared.

Signed-off-by: Alison Schofield <[email protected]>
Cc: Daniel Baluta <[email protected]>
Tested-by: Gregor Boirie <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
tools/iio/iio_generic_buffer.c

index 0e8a1f7a292d13edba366a9ad60b91dd2b47747c..ae68bf0e2d51fe63fed291f2bb84842bee1d8a64 100644 (file)
@@ -348,7 +348,7 @@ int main(int argc, char **argv)
        int notrigger = 0;
        char *dummy;
 
-       struct iio_channel_info *channels;
+       struct iio_channel_info *channels = NULL;
 
        register_cleanup();