diff --git a/glib/goption.c b/glib/goption.c index 587eb1fb446194323585bc640e6f4aab92e7b07b..b0fb80c94df597735439bb49f8f7567bba204d71 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -1833,8 +1833,10 @@ platform_get_argv0 (void) NULL)) return NULL; - /* Sanity check for a NUL terminator. */ - g_assert (memchr (cmdline, 0, len)); + /* g_file_get_contents() guarantees to put a NUL immediately after the + * file's contents (at cmdline[len] here), even if the file itself was + * not NUL-terminated. */ + g_assert (memchr (cmdline, 0, len + 1)); /* We could just return cmdline, but I think it's better * to hold on to a smaller malloc block; the arguments