Skip to content

Infinite loop fix when gmime-stream write to small buffer

Yoshihiko Fujita requested to merge fujita.yoshihiko/gmime:master into master

I needed head of the content thus I used DataWrapper with g_mime_stream_set_bounds. Though it fell into infinite loop.

This request is modified to accept the return value 0 of the write function.

Reproduction code:

    char ibuf[4];
    GMimeStream *in = g_mime_stream_mem_new_with_buffer(ibuf, sizeof(ibuf));
    g_mime_stream_set_bounds(in, 0, 4);
    char obuf[5];
    memset(obuf, 'a', sizeof(obuf));
    GMimeStream *out = g_mime_stream_mem_new_with_buffer(obuf, sizeof(obuf));
    g_mime_stream_write_to_stream(out, in);

Merge request reports