Added guard code to avoid issue when decoding PEM but not keeping data.
authorThomas Pornin <pornin@bolet.org>
Tue, 5 Jun 2018 13:18:27 +0000 (15:18 +0200)
committerThomas Pornin <pornin@bolet.org>
Tue, 5 Jun 2018 13:18:27 +0000 (15:18 +0200)
src/codec/pemdec.c
src/codec/pemdec.t0

index db8f0e6..b599f84 100644 (file)
@@ -441,7 +441,9 @@ br_pem_decoder_run(void *t0ctx)
                                /* flush-buf */
 
        if (CTX->ptr > 0) {
                                /* flush-buf */
 
        if (CTX->ptr > 0) {
-               CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr);
+               if (CTX->dest) {
+                       CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr);
+               }
                CTX->ptr = 0;
        }
 
                CTX->ptr = 0;
        }
 
index d76be44..4ebf0dd 100644 (file)
@@ -204,7 +204,9 @@ cc: write8 ( x -- ) {
 \ Flush the output buffer.
 cc: flush-buf ( -- ) {
        if (CTX->ptr > 0) {
 \ Flush the output buffer.
 cc: flush-buf ( -- ) {
        if (CTX->ptr > 0) {
-               CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr);
+               if (CTX->dest) {
+                       CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr);
+               }
                CTX->ptr = 0;
        }
 }
                CTX->ptr = 0;
        }
 }