Skip to content

Commit

Permalink
Cherry-pick 275364@main (fbc96c3). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=270137

    Add null check in SQLiteIDBBackingStore::getAllIndexRecords
    https://bugs.webkit.org/show_bug.cgi?id=270137
    rdar://113116109

    Reviewed by Chris Dumez.

    Crash traces indicate SQLiteIDBBackingStore may fail to find valid object store for requested operation, so return error
    instead of crashing network process in that case.

    * Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
    (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
    (WebCore::IDBServer::SQLiteIDBBackingStore::getAllObjectStoreRecords):
    (WebCore::IDBServer::SQLiteIDBBackingStore::getAllIndexRecords):

    Canonical link: https://commits.webkit.org/275364@main

Canonical link: https://commits.webkit.org/274313.186@webkitglib/2.44
  • Loading branch information
szewai authored and aperezdc committed May 1, 2024
1 parent 45a128e commit 5f38289
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@ IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transacti

auto* objectStoreInfo = infoForObjectStore(objectStoreID);
if (!objectStoreInfo)
return IDBError { ExceptionCode::InvalidStateError, "Object store cannot be found in the backing store"_s };
return IDBError { ExceptionCode::InvalidStateError, "Object store cannot be found in the database"_s };

auto key = keyRange.lowerKey;
if (key.isNull())
Expand Down Expand Up @@ -2284,9 +2284,8 @@ IDBError SQLiteIDBBackingStore::getAllObjectStoreRecords(const IDBResourceIdenti
}

auto* objectStoreInfo = infoForObjectStore(getAllRecordsData.objectStoreIdentifier);
ASSERT(objectStoreInfo);
if (!objectStoreInfo)
return IDBError { ExceptionCode::UnknownError, "Failed to look up IDBObjectStoreInfo from identifier"_s };
return IDBError { ExceptionCode::InvalidStateError, "Object store cannot be found in the database"_s };

result = { getAllRecordsData.getAllType, objectStoreInfo->keyPath() };

Expand Down Expand Up @@ -2361,7 +2360,9 @@ IDBError SQLiteIDBBackingStore::getAllIndexRecords(const IDBResourceIdentifier&
}

auto* objectStoreInfo = infoForObjectStore(getAllRecordsData.objectStoreIdentifier);
ASSERT(objectStoreInfo);
if (!objectStoreInfo)
return IDBError { ExceptionCode::InvalidStateError, "Object store cannot be found in the database"_s };

result = { getAllRecordsData.getAllType, objectStoreInfo->keyPath() };

uint32_t currentCount = 0;
Expand Down

0 comments on commit 5f38289

Please sign in to comment.