ref: 743c45024adba0fd2748687dac327ae9bb54b0ab
parent: ab56ad8a3280b663e54ba785df56ad3be4213f91
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Jun 2 09:11:39 EDT 2021
stream: close the filter after use
--- a/stream.c
+++ b/stream.c
@@ -22,7 +22,7 @@
Buffer b, x;
Object *of, **flts;
Filter *f;
- int i, nflts;
+ int i, nflts, r;
s = nil;
if(pdfeval(&o)->type != Ostream){ /* FIXME open a string object as a stream as well? */
@@ -57,10 +57,14 @@
if((f = filteropen(flts[i]->name, o)) == nil)
goto err;
bufinit(&x, nil, 0);
- if(filterrun(f, &b, &x) != 0){
+
+ r = filterrun(f, &b, &x);
+ filterclose(f);
+ if(r != 0){
buffree(&x);
goto err;
}
+
if(!bufeof(&b))
fprint(2, "buffer has %d bytes left\n", bufleft(&b));
buffree(&b);