* Get the correct buffer size under fmemopen/torify
* Flush only if needed, avoid memory leak
* Initialize variables for eye sanity
fseeko (s->fpin, b->offset, 0);
#ifdef USE_FMEMOPEN
- char *temp;
- size_t tempsize;
+ char *temp = NULL;
+ size_t tempsize = 0;
#endif
/* see if we need to decode this part before processing it */
{
b->length = ftello (s->fpout);
b->offset = 0;
+#ifdef USE_FMEMOPEN
+ /* When running under torify, safe_fclose(&s->fpout) does not seem to
+ * update tempsize. On the other hand, fflush does. See
+ * https://github.com/neomutt/neomutt/issues/440 */
+ fflush (s->fpout);
+#endif
safe_fclose (&s->fpout);
/* restore final destination and substitute the tempfile for input */
/* restore the original source stream */
safe_fclose (&s->fpin);
#ifdef USE_FMEMOPEN
- if (tempsize)
- FREE(&temp);
+ FREE(&temp);
#endif
s->fpin = fp;
}