Fix bug in sampled decodes

BUG=skia:

Review URL: https://codereview.chromium.org/1417993006
diff --git a/src/codec/SkSampledCodec.cpp b/src/codec/SkSampledCodec.cpp
index 5302149..d5fbd0f 100644
--- a/src/codec/SkSampledCodec.cpp
+++ b/src/codec/SkSampledCodec.cpp
@@ -215,11 +215,12 @@
                             dstHeight, y + 1);
                     return SkCodec::kIncompleteInput;
                 }
-                int linesToSkip = SkTMin(sampleY - 1, dstHeight - y - 1);
-                if (!fCodec->skipScanlines(linesToSkip)) {
-                    fCodec->fillIncompleteImage(info, pixels, rowBytes, options.fZeroInitialized,
-                            dstHeight, y + 1);
-                    return SkCodec::kIncompleteInput;
+                if (y < dstHeight - 1) {
+                    if (!fCodec->skipScanlines(sampleY - 1)) {
+                        fCodec->fillIncompleteImage(info, pixels, rowBytes,
+                                options.fZeroInitialized, dstHeight, y + 1);
+                        return SkCodec::kIncompleteInput;
+                    }
                 }
                 pixelPtr = SkTAddOffset<void>(pixelPtr, rowBytes);
             }