Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory watch crash #63

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/core/scripthost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ ScriptHost::ScriptHost(Pack* pack, lua_State *L, Tracker *tracker)
for (size_t i=0; i<_memoryWatches.size(); i++) {
// NOTE: since watches can change in a callback, we use vector
auto& w = _memoryWatches[i];
auto name = w.name;
auto newData = _autoTracker->read((unsigned)w.addr, (unsigned)w.len);
if (w.data != newData) {
DEBUG_printf(" %s changed\n", w.name.c_str());
Expand All @@ -80,9 +79,7 @@ ScriptHost::ScriptHost(Pack* pack, lua_State *L, Tracker *tracker)
w.data = newData;
w.dirty = true;
}
if (_memoryWatches.size() <= i) break;
if (_memoryWatches[i].name != name) // current item not unchanged
i--;
// NOTE: we run the user callbacks in runMemoryWatchCallbacks
}
}};
_autoTracker->onVariablesChanged += {this, [this](void*, const std::list<std::string>& vars) {
Expand Down Expand Up @@ -410,6 +407,6 @@ void ScriptHost::runMemoryWatchCallbacks()
if (_memoryWatches[i].name != name)
i--; // watch at i changed (was removed)
else if (res != false)
w.dirty = false; // watch returned non-false
_memoryWatches[i].dirty = false; // watch returned non-false
}
}
Loading