]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
test: Check asprintf() return code
authorGuillem Jover <guillem@hadrons.org>
Mon, 30 Nov 2015 22:48:17 +0000 (23:48 +0100)
committerGuillem Jover <guillem@hadrons.org>
Mon, 30 Nov 2015 22:48:50 +0000 (23:48 +0100)
test/proctitle.c

index 5f546c79fb4977286ab3f37cf7d8f7cefdc1d6eb..c457dc9ef93c45f6ae0b9a3f3805580307d37140 100644 (file)
@@ -36,6 +36,7 @@ main(int argc, char **argv, char **envp)
        const char newtitle_base[] = "test arg1 arg2";
        char *newtitle_full;
        char *envvar;
+       int rc;
 
 #ifdef TEST_USE_SETPROCTITLE_INIT
        setproctitle_init(argc, argv, envp);
@@ -44,7 +45,8 @@ main(int argc, char **argv, char **envp)
        setproctitle("-test %s arg2", "arg1");
        assert(strcmp(argv[0], newtitle_base) == 0);
 
-       asprintf(&newtitle_full, "%s: %s", getprogname(), newtitle_base);
+       rc = asprintf(&newtitle_full, "%s: %s", getprogname(), newtitle_base);
+       assert(rc > 0);
        setproctitle("test %s arg2", "arg1");
        assert(strcmp(argv[0], newtitle_full) == 0);
        free(newtitle_full);