lib/model: Catch racy nil deref in ClusterConfig (#5106)

This commit is contained in:
Simon Frei 2018-08-11 09:10:29 +02:00 committed by Jakob Borg
parent 54d610878d
commit dfe4008607

View File

@ -953,12 +953,17 @@ func (m *Model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
if cfg.Paused { if cfg.Paused {
continue continue
} }
fs, ok := m.folderFiles[folder.ID]
if !ok {
// Shouldn't happen because !cfg.Paused, but might happen
// if the folder is about to be unpaused, but not yet.
continue
}
if !folder.DisableTempIndexes { if !folder.DisableTempIndexes {
tempIndexFolders = append(tempIndexFolders, folder.ID) tempIndexFolders = append(tempIndexFolders, folder.ID)
} }
fs := m.folderFiles[folder.ID]
myIndexID := fs.IndexID(protocol.LocalDeviceID) myIndexID := fs.IndexID(protocol.LocalDeviceID)
mySequence := fs.Sequence(protocol.LocalDeviceID) mySequence := fs.Sequence(protocol.LocalDeviceID)
var startSequence int64 var startSequence int64