Index: funcs/func_env.c =================================================================== --- funcs/func_env.c (revision 390821) +++ funcs/func_env.c (working copy) @@ -541,7 +541,7 @@ /* Don't go past the length requested */ if (off_i + toappend > offset + length) { - toappend = length - off_i; + toappend = offset + length - off_i; } ast_str_append_substr(buf, len, fbuf, toappend);