[PATCH evemu] evemu-record.c: fix memory access in error path
Martin Kepplinger
martink at posteo.de
Sun Sep 17 11:07:15 UTC 2017
In case the output file could not have been opened, it is accessed anyways
although it's zero, resulting in a segmentation fault.
So let's free it in the out-path only if allocated before.
Signed-off-by: Martin Kepplinger <martink at posteo.de>
---
Hi Peter,
Thanks for pointing that out. You're right, only fclose(NULL) is a
problem here. Tested.
thanks,
martin
tools/evemu-record.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/evemu-record.c b/tools/evemu-record.c
index 56572bb..40693ff 100644
--- a/tools/evemu-record.c
+++ b/tools/evemu-record.c
@@ -339,7 +339,7 @@ int main(int argc, char *argv[])
out:
free(device);
close(fd);
- if (output != stdout) {
+ if (output && output != stdout) {
fclose(output);
output = stdout;
}
--
2.11.0
More information about the Input-tools
mailing list