Skip to content

Commit

Permalink
Merge pull request #551 from mbbsemu/textvar-race
Browse files Browse the repository at this point in the history
Fix a Race Condition if a disconnect were to happen during processing…
  • Loading branch information
paladine committed Mar 14, 2022
2 parents a983417 + bb56c67 commit 227d3be
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 227d3be

Please sign in to comment.