Added guard code to avoid issue when decoding PEM but not keeping data.

This commit is contained in:
Thomas Pornin 2018-06-05 15:18:27 +02:00
parent 05520e8eae
commit d69276c18d
2 changed files with 6 additions and 2 deletions

View file

@ -441,7 +441,9 @@ br_pem_decoder_run(void *t0ctx)
/* flush-buf */ /* flush-buf */
if (CTX->ptr > 0) { if (CTX->ptr > 0) {
if (CTX->dest) {
CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr); CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr);
}
CTX->ptr = 0; CTX->ptr = 0;
} }

View file

@ -204,7 +204,9 @@ cc: write8 ( x -- ) {
\ Flush the output buffer. \ Flush the output buffer.
cc: flush-buf ( -- ) { cc: flush-buf ( -- ) {
if (CTX->ptr > 0) { if (CTX->ptr > 0) {
if (CTX->dest) {
CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr); CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr);
}
CTX->ptr = 0; CTX->ptr = 0;
} }
} }