segment: Fix 1-byte read past initialized data when file ends in CR.
[pspp] / src / language / lexer / segment.c
index 519f6ec9f23e4abf35fb8efe2abcc330394171db..4a6fefb4c25d1e7c1441cd1a6a8d43f5b76b1873 100644 (file)
@@ -1042,7 +1042,7 @@ segmenter_parse_mid_command__ (struct segmenter *s,
           if (ofs < 0)
             return -1;
 
-          if (input[ofs - 1] == '\r' && input[ofs] == '\n')
+          if (ofs < n && input[ofs - 1] == '\r' && input[ofs] == '\n')
             {
               if (ofs == 1)
                 {