Add check for invalid DialogId in database.
GitOrigin-RevId: ac28b2afb276743fe203a25f53e0ff69e4e3e08d
This commit is contained in:
parent
4a8ba5075a
commit
b9cbd43e96
@ -10676,7 +10676,9 @@ void MessagesManager::on_get_dialogs_from_database(vector<BufferSlice> &&dialogs
|
||||
DialogDate max_dialog_date = MIN_DIALOG_DATE;
|
||||
for (auto &dialog : dialogs) {
|
||||
Dialog *d = on_load_dialog_from_database(std::move(dialog));
|
||||
CHECK(d != nullptr);
|
||||
if (d == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DialogDate dialog_date(d->order, d->dialog_id);
|
||||
if (max_dialog_date < dialog_date) {
|
||||
@ -21674,6 +21676,11 @@ MessagesManager::Dialog *MessagesManager::on_load_dialog_from_database(const Res
|
||||
parse(flags, dialog_id_parser);
|
||||
parse(dialog_id, dialog_id_parser);
|
||||
|
||||
if (!dialog_id.is_valid()) {
|
||||
LOG(ERROR) << "Failed to parse dialog_id from blob. Database is broken";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto old_d = get_dialog(dialog_id);
|
||||
if (old_d != nullptr) {
|
||||
return old_d;
|
||||
|
@ -72,6 +72,7 @@ struct EncryptedInputFile {
|
||||
store(key_fingerprint, storer);
|
||||
}
|
||||
|
||||
EncryptedInputFile() = default;
|
||||
EncryptedInputFile(Type type, int64 id, int64 access_hash, int32 parts, int32 key_fingerprint)
|
||||
: type(type), id(id), access_hash(access_hash), parts(parts), key_fingerprint(key_fingerprint) {
|
||||
}
|
||||
|
Reference in New Issue
Block a user