Ver código fonte

tools: iio: iio_generic_buffer: initialize channel array pointer

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 <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Tested-by: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Alison Schofield 9 anos atrás
pai
commit
ddbc719f99
1 arquivos alterados com 1 adições e 1 exclusões
  1. 1 1
      tools/iio/iio_generic_buffer.c

+ 1 - 1
tools/iio/iio_generic_buffer.c

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