diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c
index 65feb1a..fed1a53 100644
--- a/libavcodec/lcldec.c
+++ b/libavcodec/lcldec.c
@@ -415,7 +415,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
         for (row = height - 1; row >= 0; row--) {
             pixel_ptr = row * c->pic.linesize[0];
             memcpy(outptr + pixel_ptr, encoded, 3 * width);
-            encoded += 3 * width;
+            encoded += 3 * width + (width & 3);
         }
         break;
     case IMGTYPE_YUV411:
@@ -512,7 +512,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:2:2.\n");
         break;
     case IMGTYPE_RGB24:
-        c->decomp_size = basesize * 3;
+        c->decomp_size = basesize * 3 + (avctx->width & 3) * avctx->height;
         max_decomp_size = max_basesize * 3;
         avctx->pix_fmt = PIX_FMT_BGR24;
         av_log(avctx, AV_LOG_DEBUG, "Image type is RGB 24.\n");
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 16976ea..f886e73 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -100,7 +100,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     for(i = avctx->height - 1; i >= 0; i--) {
         c->zstream.next_in = p->data[0]+p->linesize[0]*i;
-        c->zstream.avail_in = avctx->width*3;
+        c->zstream.avail_in = avctx->width*3 + (avctx->width & 3);
         zret = deflate(&c->zstream, Z_NO_FLUSH);
         if (zret != Z_OK) {
             av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret);
