Skip to content

Commit 246f8b7

Browse files
authored
Merge pull request #3 from Leont/null-byte
Add final null-byte to tokens
2 parents 7a2941f + cd64e7b commit 246f8b7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Token.xs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ get(ctx)
115115
size_t i, curr;
116116

117117
output = newSVpvn("", 0);
118-
SvGROW(output, ctx->token_length);
118+
SvGROW(output, ctx->token_length + 1);
119119
SvCUR_set(output, ctx->token_length);
120-
outputp = SvPV(output, ctx->token_length);
120+
outputp = SvPV_nolen(output);
121121

122122
for (i=0; i<ctx->token_length; i++) {
123123
while((curr = (get_new_byte(ctx) & ctx->mask)) >= ctx->alphabet_length) ;
124124
outputp[i] = ctx->alphabet[curr];
125125
}
126+
outputp[i] = '\0';
126127

127128
RETVAL = output;
128129

0 commit comments

Comments
 (0)