From f02d56a76e4ac5a6ebc65e5277250cbe73ba6ca0 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sat, 26 Mar 2011 01:01:17 +0100 Subject: Corrected access to freed memory location. Reported by Vitaly Kruglikov. --- lib/opencdk/stream.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/opencdk/stream.c b/lib/opencdk/stream.c index 4dfa8f1dbd..0f3660f6d9 100644 --- a/lib/opencdk/stream.c +++ b/lib/opencdk/stream.c @@ -761,6 +761,7 @@ stream_fp_replace (cdk_stream_t s, FILE ** tmp) rc = fclose (s->fp); if (rc) { + s->fp = NULL; gnutls_assert (); return CDK_File_Error; } @@ -819,11 +820,12 @@ stream_filter_write (cdk_stream_t s) if (!rc) rc = cdk_stream_seek (s, 0); if (rc) - { - _cdk_log_debug ("filter [close]: fd=%d\n", fileno (f->tmp)); - fclose (f->tmp); - break; - } + { + _gnutls_read_log ("filter [close]: fd=%d\n", fileno (f->tmp)); + fclose (f->tmp); + f->tmp = NULL; + break; + } } return rc; } @@ -958,13 +960,13 @@ cdk_stream_read (cdk_stream_t s, void *buf, size_t buflen) { rc = stream_filter_read (s); if (rc) - { - s->error = rc; - if (feof (s->fp)) - s->flags.eof = 1; - gnutls_assert (); - return EOF; - } + { + s->error = rc; + if (s->fp && feof (s->fp)) + s->flags.eof = 1; + gnutls_assert (); + return EOF; + } s->flags.filtrated = 1; } -- cgit v1.2.1