Fix downsampling check in crop.

Bug: 8586301
Change-Id: I4c5441f779122adb984368609cfea39a60190848
diff --git a/src/com/android/gallery3d/filtershow/crop/CropLoader.java b/src/com/android/gallery3d/filtershow/crop/CropLoader.java
index d2a681f..132d6c1 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropLoader.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropLoader.java
@@ -144,14 +144,16 @@
 
             // Find best downsampling size
             int imageSide = Math.max(w, h);
+            options.inSampleSize = 1;
             if (imageSide > maxSideLength) {
                 int shifts = 1 + Integer.numberOfLeadingZeros(maxSideLength)
                         - Integer.numberOfLeadingZeros(imageSide);
-                options.inSampleSize = 1 << shifts;
+                options.inSampleSize <<= shifts;
             }
 
             // Make sure sample size is reasonable
-            if (0 >= (int) (Math.min(w, h) / options.inSampleSize)) {
+            if (options.inSampleSize <= 0 ||
+                    0 >= (int) (Math.min(w, h) / options.inSampleSize)) {
                 return null;
             }