From: Thomas Pornin Date: Tue, 5 Jun 2018 13:18:27 +0000 (+0200) Subject: Added guard code to avoid issue when decoding PEM but not keeping data. X-Git-Tag: v0.6~9 X-Git-Url: https://bearssl.org/gitweb//home/git/?a=commitdiff_plain;h=d69276c18d55480e1bfa4b4c28b31062a706f6f0;p=BearSSL Added guard code to avoid issue when decoding PEM but not keeping data. --- diff --git a/src/codec/pemdec.c b/src/codec/pemdec.c index db8f0e6..b599f84 100644 --- a/src/codec/pemdec.c +++ b/src/codec/pemdec.c @@ -441,7 +441,9 @@ br_pem_decoder_run(void *t0ctx) /* 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; } diff --git a/src/codec/pemdec.t0 b/src/codec/pemdec.t0 index d76be44..4ebf0dd 100644 --- a/src/codec/pemdec.t0 +++ b/src/codec/pemdec.t0 @@ -204,7 +204,9 @@ cc: write8 ( x -- ) { \ 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; } }