Blob Blame History Raw
diff -ruN -x '*~' ctags-5.7/vim.c ctags-5.7/vim.c
--- ctags-5.7/vim.c	2006-10-26 12:06:21.000000000 +0900
+++ ctags-5.7/vim.c	2009-08-28 22:21:31.000000000 +0900
@@ -328,7 +328,7 @@
 	 */
 	const unsigned char *cp = line;
 
-	if ( (int) *cp == '\\' ) 
+	if ( cp && ( (int) *cp == '\\' ) ) 
 	{
 		/*
 		 * We are recursively calling this function is the command
@@ -350,9 +350,10 @@
 		while (*cp && isspace ((int) *cp))
 			++cp; 
 	}
-	else if ( (!strncmp ((const char*) line, "comp", (size_t) 4) == 0) && 
-		     (!strncmp ((const char*) line, "comc", (size_t) 4) == 0) && 
-				(strncmp ((const char*) line, "com", (size_t) 3) == 0) )
+	else if ( line && 
+                     (!strncmp ((const char*) line, "comp", (size_t) 4) == 0) && 
+		                (!strncmp ((const char*) line, "comc", (size_t) 4) == 0) && 
+				          (strncmp ((const char*) line, "com", (size_t) 3) == 0) )
 	{
 		cp += 2;
 		if ((int) *++cp == 'm' && (int) *++cp == 'a' &&
@@ -394,6 +395,14 @@
 			while (*cp && !isspace ((int) *cp))
 				++cp; 
 		}
+		else if (!isalnum ((int) *cp))
+		{
+			/*
+			 * Broken syntax: throw away this line
+			 */
+			cmdProcessed = TRUE;
+			goto cleanUp;
+		}
 	} while ( *cp &&  !isalnum ((int) *cp) );
 
 	if ( ! *cp )