Keep track of the actual amount of decoded bytes, which can be less than 3 when
we decode the last bits of a base64 message.
guint cin;
gchar out[3];
guint cout;
+ guint coutl;
} DecodeCtx;
static GstRTSPResult read_line (gint fd, guint8 * buffer, guint * idx,
gint r;
while (size > 0) {
- while (size > 0 && ctx->cout < 3) {
+ while (size > 0 && ctx->cout < ctx->coutl) {
/* we have some leftover bytes */
*buffer++ = ctx->out[ctx->cout];
ctx->cout++;
r = g_base64_decode_step ((const gchar *) ctx->in, 4,
(guchar *) ctx->out, &ctx->state, &ctx->save);
ctx->cout = 0;
+ ctx->coutl = r;
ctx->cin = 0;
}
}