mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
extract: finish: fix bad assertion - ‘idx’ may be equal to ‘size’
‘idx’ is where _new_ data should be pushed into the buffer. Thus it is perfectly valid for it to be equal to ‘size’ - it just means we need to allocate more space before pushing data to it.
This commit is contained in:
parent
4849e8f874
commit
07078da0f0
1 changed files with 5 additions and 2 deletions
|
|
@ -72,11 +72,14 @@ extract_finish(struct extraction_context *ctx, char **text, size_t *len)
|
|||
ctx->buf[ctx->idx] = L'\0';
|
||||
} else {
|
||||
assert(ctx->idx > 0);
|
||||
assert(ctx->idx < ctx->size);
|
||||
assert(ctx->idx <= ctx->size);
|
||||
if (ctx->buf[ctx->idx - 1] == L'\n')
|
||||
ctx->buf[ctx->idx - 1] = L'\0';
|
||||
else
|
||||
else {
|
||||
if (!ensure_size(ctx, 1))
|
||||
goto out;
|
||||
ctx->buf[ctx->idx] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
size_t _len = wcstombs(NULL, ctx->buf, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue