fix an out-by-one error that was causing segfaults for single line commands

ending with a // comment
This commit is contained in:
Bill Currie 2002-08-21 22:52:29 +00:00
parent 9bf3ccd813
commit 42c03bb9e1

View file

@ -132,16 +132,15 @@ COM_extract_line (cbuf_t *cbuf)
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (text[i] == '"') if (text[i] == '"')
quotes++; quotes++;
if (!(quotes & 1)) { if (!(quotes & 1)) { // don't break if inside a quoted string
if (text[i] == ';') if (text[i] == ';')
// don't break if inside a quoted string
break; break;
if (text[i] == '/' && text[i + 1] == '/') { if (text[i] == '/' && text[i + 1] == '/') {
int j = i; int j = i;
while (j < len && text[j] != '\n' && text[j] != '\r') while (j < len && text[j] != '\n' && text[j] != '\r')
j++; j++;
dstring_snip (cbuf->buf, i, j - i); dstring_snip (cbuf->buf, i, j - i);
len -= j - i; break;
} }
} }
if (text[i] == '\n' || text[i] == '\r') if (text[i] == '\n' || text[i] == '\r')