From d82b8b0789e75d150a8cd44fa84d838c5edc1b71 Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Thu, 3 Mar 2016 11:58:52 +0200 Subject: [PATCH] replay: do not use argv after g_option_context_parse Apparently, after using g_option_context_parse with G_OPTION_REMAINING argv is modified and should not be used. This patch uses "file" instead of "argv" and makes sure file is freed later. No free is called upon error - exit takes care of it. --- server/tests/replay.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/tests/replay.c b/server/tests/replay.c index f3b670f2..91bcf2bb 100644 --- a/server/tests/replay.c +++ b/server/tests/replay.c @@ -350,12 +350,12 @@ int main(int argc, char **argv) } else { fd = fopen(file[0], "r"); } + if (fd == NULL) { + g_printerr("error opening %s\n", file[0]); + exit(1); + } g_strfreev(file); file = NULL; - if (fd == NULL) { - g_printerr("error opening %s\n", argv[1]); - return 1; - } if (fcntl(fileno(fd), FD_CLOEXEC) < 0) { perror("fcntl failed"); exit(1);