Skip to content

ensure_capacity() does not always ensure at least one byte of capacity #78

@link2xt

Description

@link2xt

This is a follow-up to #66 bug. While setting the number of bytes requested by the parser in #74 made the issue harder to reproduce and fixed particular testcase, the original issue of closed state being erroneously set was not investigated.

I looked into it and found that async-imap sometimes tries to read into a zero-sized buffer, then treats zero read bytes as the indication of closed stream:
https://github.com/async-email/async-imap/blob/1963cedefc9828ce994eb63e01afcf5c1c65d4c9/src/imap_stream.rs#L288-L303

ensure_capacity() at the beginning of this snippet is supposed to ensure at least one byte is free in the buffer, but due to a bug it sometimes does not allocate even a single byte. I reproduced the issue at #77.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions