Bug 1106347 - Don't die when retrieving over-large favicons from the database. r=mfinkle

This commit is contained in:
Richard Newman 2014-12-05 16:54:47 -08:00
Родитель bcfa00a2e3
Коммит 8f7c48fbe2
1 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -1001,6 +1001,7 @@ public class LocalBrowserDB {
new String[] { faviconURL },
null);
boolean shouldDelete = false;
byte[] b = null;
try {
if (!c.moveToFirst()) {
@ -1008,11 +1009,28 @@ public class LocalBrowserDB {
}
final int faviconIndex = c.getColumnIndexOrThrow(Favicons.DATA);
try {
b = c.getBlob(faviconIndex);
} catch (IllegalStateException e) {
// This happens when the blob is more than 1MB: Bug 1106347.
// Delete that row.
shouldDelete = true;
}
} finally {
c.close();
}
if (shouldDelete) {
try {
Log.d(LOGTAG, "Deleting invalid favicon.");
cr.delete(mFaviconsUriWithProfile,
Favicons.URL + " = ?",
new String[] { faviconURL });
} catch (Exception e) {
// Do nothing.
}
}
if (b == null) {
return null;
}