From 0eff530775f94be45fba133eb58db0693751df2e Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 28 May 2018 18:29:15 +0000 Subject: [PATCH] strsep.3: don't silently ignore errors Reported by: bde MFC with: r334275 --- lib/libc/string/strsep.3 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libc/string/strsep.3 b/lib/libc/string/strsep.3 index e888ecfaa850..0dbf1294db27 100644 --- a/lib/libc/string/strsep.3 +++ b/lib/libc/string/strsep.3 @@ -86,9 +86,10 @@ to parse a string, and prints each token in separate line: char *token, *string, *tofree; tofree = string = strdup("abc,def,ghi"); -if (string != NULL) - while ((token = strsep(&string, ",")) != NULL) - printf("%s\en", token); +if (string == NULL) + err(1, "strdup"); +while ((token = strsep(&string, ",")) != NULL) + printf("%s\en", token); free(tofree); .Ed