From 5c5506e41624e15c6e91a9cd3629706fe7a9ad86 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 21 Mar 2015 00:11:25 +0100 Subject: fix for #1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/krandom.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/krandom.c b/src/krandom.c index 1b5e284..54eca43 100644 --- a/src/krandom.c +++ b/src/krandom.c @@ -128,11 +128,13 @@ int main(int argc, char** argv) ssize_t got; int r, fd = -1, verbose = 0; - execname = *argv; + execname = argc ? *argv : "krandom"; memset(&state, 0, sizeof(libkeccak_state_t)); libkeccak_generalised_spec_initialise(&gspec); + if (!argc) + goto skip_argv_parsing; args_init("Keccak-based userspace pseudorandom number generator", "krandom [options...]", NULL, @@ -156,6 +158,7 @@ int main(int argc, char** argv) if (args_opts_used("-W")) gspec.word_size = atol(LAST("-W")); if (args_opts_used("-v")) verbose = 1; + skip_argv_parsing: if ((r = make_spec(&gspec, &spec))) goto done; @@ -202,7 +205,8 @@ int main(int argc, char** argv) done: if (fd >= 0) close(fd); - args_dispose(); + if (argc) + args_dispose(); free(generated_random); libkeccak_state_fast_destroy(&state); return r; -- cgit v1.2.3-70-g09d2