summaryrefslogtreecommitdiffstats
path: root/g10/free-packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/free-packet.c')
-rw-r--r--g10/free-packet.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/g10/free-packet.c b/g10/free-packet.c
index 5d74544fc..0a61e222c 100644
--- a/g10/free-packet.c
+++ b/g10/free-packet.c
@@ -244,8 +244,13 @@ free_encrypted( PKT_encrypted *ed )
;
}
else {
- while( ed->len ) /* skip the packet */
- ed->len -= iobuf_read( ed->buf, NULL, ed->len );
+ while( ed->len ) { /* skip the packet */
+ int n = iobuf_read( ed->buf, NULL, ed->len );
+ if( n == -1 )
+ ed->len = 0;
+ else
+ ed->len -= n;
+ }
}
}
m_free(ed);
@@ -261,8 +266,13 @@ free_plaintext( PKT_plaintext *pt )
;
}
else {
- while( pt->len ) /* skip the packet */
- pt->len -= iobuf_read( pt->buf, NULL, pt->len );
+ while( pt->len ) { /* skip the packet */
+ int n = iobuf_read( pt->buf, NULL, pt->len );
+ if( n == -1 )
+ pt->len = 0;
+ else
+ pt->len -= n;
+ }
}
}
m_free(pt);