mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
fix an out-by-one error that was causing segfaults for single line commands
ending with a // comment
This commit is contained in:
parent
9bf3ccd813
commit
42c03bb9e1
1 changed files with 2 additions and 3 deletions
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue