Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 May 2018 18:29:15 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334291 - head/lib/libc/string
Message-ID:  <201805281829.w4SITFQB055010@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805281829.w4SITFQB055010>