Skip to content

Commit

Permalink
Fix a Race Condition if a disconnect were to happen during processing…
Browse files Browse the repository at this point in the history
… loop
  • Loading branch information
enusbaum committed Mar 14, 2022
1 parent a983417 commit bb56c67
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion MBBSEmu/HostProcess/ExportedModules/ExportedModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,11 @@ private protected ReadOnlySpan<byte> ProcessTextVariables(ReadOnlySpan<byte> out

var txtvarsFound = _textVariableService.ExtractVariableDefinitions(outputBuffer);

var txtvarDictionary = ChannelDictionary[ChannelNumber].SessionVariables;
//This can happen if a channel disconnects during the processing of the main loop
if (!ChannelDictionary.TryGetValue(ChannelNumber, out var channelSession))
return outputBuffer;

var txtvarDictionary = channelSession.SessionVariables;

//Get Their Values
var txtvarMemoryBase = Module.Memory.GetVariablePointer("TXTVARS");
Expand Down

0 comments on commit bb56c67

Please sign in to comment.