Commit 877732ef4d101e9b6c789e9c00f88623761fc8c4

Guillem Jover 2015-11-30T23:48:17

test: Check asprintf() return code

diff --git a/test/proctitle.c b/test/proctitle.c
index 5f546c7..c457dc9 100644
--- a/test/proctitle.c
+++ b/test/proctitle.c
@@ -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);