svn commit: samba r16200 - in trunk/source/libads: .

jra at samba.org jra at samba.org
Tue Jun 13 18:09:08 GMT 2006


Author: jra
Date: 2006-06-13 18:09:06 +0000 (Tue, 13 Jun 2006)
New Revision: 16200

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16200

Log:
Fix Klocwork #1 - ensure we test the first
strtok for NULL.
Jeremy.

Modified:
   trunk/source/libads/ads_struct.c


Changeset:
Modified: trunk/source/libads/ads_struct.c
===================================================================
--- trunk/source/libads/ads_struct.c	2006-06-13 18:09:04 UTC (rev 16199)
+++ trunk/source/libads/ads_struct.c	2006-06-13 18:09:06 UTC (rev 16200)
@@ -48,16 +48,18 @@
 
 	strlcpy(ret,field, len);
 	p=strtok(r,sep); 
-	strlcat(ret, p, len);
-
-	while ((p=strtok(NULL,sep))) {
-		char *s;
-		if (reverse)
-			asprintf(&s, "%s%s,%s", field, p, ret);
-		else
-			asprintf(&s, "%s,%s%s", ret, field, p);
-		free(ret);
-		ret = s;
+	if (p) {
+		strlcat(ret, p, len);
+	
+		while ((p=strtok(NULL,sep))) {
+			char *s;
+			if (reverse)
+				asprintf(&s, "%s%s,%s", field, p, ret);
+			else
+				asprintf(&s, "%s,%s%s", ret, field, p);
+			free(ret);
+			ret = s;
+		}
 	}
 
 	free(r);



More information about the samba-cvs mailing list