svn commit: r334291 - head/lib/libc/string

Ed Maste emaste at FreeBSD.org
Mon May 28 18:29:16 UTC 2018


Author: emaste
Date: Mon May 28 18:29:15 2018
New Revision: 334291
URL: https://svnweb.freebsd.org/changeset/base/334291

Log:
  strsep.3: don't silently ignore errors
  
  Reported by:	bde
  MFC with:	r334275

Modified:
  head/lib/libc/string/strsep.3

Modified: head/lib/libc/string/strsep.3
==============================================================================
--- head/lib/libc/string/strsep.3	Mon May 28 17:47:32 2018	(r334290)
+++ head/lib/libc/string/strsep.3	Mon May 28 18:29:15 2018	(r334291)
@@ -86,9 +86,10 @@ to parse a string, and prints each token in separate l
 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


More information about the svn-src-all mailing list