diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index e92967d..c2c8e02 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -769,7 +769,7 @@ static int tiff_decode_tag(TiffContext *s)
         break;
     case TIFF_ROWSPERSTRIP:
         if (type == TIFF_LONG && value == UINT_MAX)
-            value = s->avctx->height;
+            value = s->height;
         if (value < 1) {
             av_log(s->avctx, AV_LOG_ERROR,
                    "Incorrect value of rows per strip\n");
