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;
l -= start;
if (len > l + 1)
len = l + 1;
if (len > l)
len = l;
tmp = Hunk_TempAlloc (len);
strncpy (tmp, s, len - 1);
tmp[len - 1] = 0;
tmp = Hunk_TempAlloc (len + 1);
strncpy (tmp, s, len);
tmp[len] = 0;
RETURN_STRING (pr, tmp);
}