Index: sync/syncable/directory_backing_store.cc |
diff --git a/sync/syncable/directory_backing_store.cc b/sync/syncable/directory_backing_store.cc |
index ec28a53d661a47fcc9baaa99774301c01d953701..55a01e6c352830ee0f9d345c02c1f3c05b40f828 100644 |
--- a/sync/syncable/directory_backing_store.cc |
+++ b/sync/syncable/directory_backing_store.cc |
@@ -123,6 +123,16 @@ scoped_ptr<EntryKernel> UnpackEntry(sql::Statement* statement) { |
kernel->mutable_ref(static_cast<AttachmentMetadataField>(i)).ParseFromArray( |
statement->ColumnBlob(i), statement->ColumnByteLength(i)); |
} |
+ |
+ // Sanity check on positions. We risk strange and rare crashes if our |
+ // assumptions about unique position values are broken. |
+ if (kernel->ShouldMaintainPosition() && |
+ !kernel->ref(UNIQUE_POSITION).IsValid()) { |
+ DVLOG(1) << "Unpacked invalid position on an entity that should have a " |
+ << "valid position. Assuming the DB is corrupt."; |
+ return scoped_ptr<EntryKernel>(); |
+ } |
+ |
return kernel.Pass(); |
} |