Skip to content

Commit

Permalink
Merge branch 'hotfix/3.1.2' into release/3.2
Browse files Browse the repository at this point in the history
Conflicts:
	WordPress/src/main/java/org/wordpress/android/GCMIntentService.java
  • Loading branch information
maxme committed Sep 12, 2014
2 parents e3795fe + 0ebd130 commit c7476fc
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,17 @@ public static byte[] createThumbnailFromUri(Context context,
optActual.inSampleSize = scale;

// Get the roughly resized bitmap
Bitmap bmpResized;
final Bitmap bmpResized;
try {
bmpResized = BitmapFactory.decodeFile(filePath, optActual);
} catch (OutOfMemoryError e) {
AppLog.e(AppLog.T.UTILS, "OutOfMemoryError Error in setting image: " + e);
return null;
}

if (bmpResized == null)
if (bmpResized == null) {
return null;
}

ByteArrayOutputStream stream = new ByteArrayOutputStream();

Expand Down Expand Up @@ -490,7 +491,18 @@ public static byte[] createThumbnailFromUri(Context context,
} catch (OutOfMemoryError e) {
AppLog.e(AppLog.T.UTILS, "OutOfMemoryError Error in setting image: " + e);
return null;
} catch (NullPointerException e) {
// See: https://github.com/wordpress-mobile/WordPress-Android/issues/1844
AppLog.e(AppLog.T.UTILS, "Bitmap.createBitmap has thrown a NPE internally. This should never happen: " + e);
return null;
}

if (bmpRotated == null) {
// Fix an issue where bmpRotated is null even if the documentation doesn't say Bitmap.createBitmap can return null.
// See: https://github.com/wordpress-mobile/WordPress-Android/issues/1848
return null;
}

bmpRotated.compress(fmt, 100, stream);
bmpResized.recycle();
bmpRotated.recycle();
Expand Down

0 comments on commit c7476fc

Please sign in to comment.