segment: Fix buffer overrun error in segmenter_detect_command_name__().
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 6 Jan 2016 01:45:37 +0000 (17:45 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 6 Jan 2016 01:47:57 +0000 (17:47 -0800)
Found by valgrind.

src/language/lexer/segment.c

index 0c4a6bd8007201e1ce685d21f229237f9e46b9f9..52ff37a457bc13597a1a2f861911f3e49ef94bd4 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011, 2013, 2016 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1010,6 +1010,9 @@ segmenter_detect_command_name__ (const char *input, size_t n, int ofs)
 
       ofs += mblen;
     }
+  if (!ofs)
+    return 0;
+
   if (input[ofs - 1] == '.')
     ofs--;