From b45571e9d06827c6ee695e2d1d694a5dded7ebdc Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Thu, 10 May 2012 14:51:12 +0200 Subject: [PATCH] Set argv[argc] to 0 in 'config_args' libc plugin Fixes #201. --- os/src/lib/config_args/config_args.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/os/src/lib/config_args/config_args.cc b/os/src/lib/config_args/config_args.cc index 73ab5b7ab4..df6fd4f559 100644 --- a/os/src/lib/config_args/config_args.cc +++ b/os/src/lib/config_args/config_args.cc @@ -47,7 +47,7 @@ void init_config_args(void) if (argc == 0) return; - argv = (char**)env()->heap()->alloc(argc * sizeof(char*)); + argv = (char**)env()->heap()->alloc((argc + 1) * sizeof(char*)); /* read the arguments */ Xml_node arg_node = config()->xml_node().sub_node("arg"); @@ -62,6 +62,8 @@ void init_config_args(void) } } catch (Xml_node::Nonexistent_sub_node) { } + argv[argc] = 0; + /* register command-line arguments at Genode's startup code */ genode_argc = argc; genode_argv = argv;