Fix an off-by-one error in qwe's substr implementation.

This commit is contained in:
Bill Currie 2012-07-14 08:07:41 +09:00
parent fcf7150c62
commit 45311e55c2

View file

@ -171,12 +171,12 @@ PF_substr (progs_t *pr)
s += start; s += start;
l -= start; l -= start;
if (len > l + 1) if (len > l)
len = l + 1; len = l;
tmp = Hunk_TempAlloc (len); tmp = Hunk_TempAlloc (len + 1);
strncpy (tmp, s, len - 1); strncpy (tmp, s, len);
tmp[len - 1] = 0; tmp[len] = 0;
RETURN_STRING (pr, tmp); RETURN_STRING (pr, tmp);
} }