Skip to content

Commit

Permalink
fix off-by-one error
Browse files Browse the repository at this point in the history
- buf.length = 65536, len = 65535, n = 65535, beg = 0
  buf[65535 + 1] = '\0' -> RangeError
  buf[65535] = '\0' -> correct
  • Loading branch information
MartinNowak committed Aug 24, 2015
1 parent e510c00 commit de29808
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/link.d
Expand Up @@ -90,7 +90,7 @@ static if (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)
const(size_t) n = fread(&buffer[beg], 1, len - beg, stream);
if (beg + n < len && ferror(stream))
return -1;
buffer[(end = beg + n) + 1] = '\0';
buffer[(end = beg + n)] = '\0';
// search error message, stop at last complete line
const(char)* lastSep = strrchr(buffer.ptr, '\n');
if (lastSep)
Expand Down

0 comments on commit de29808

Please sign in to comment.