lume.hotswap - Fix three edge cases that lead to a crash#27
Open
rameshvarun wants to merge 1 commit intorxi:masterfrom
Open
lume.hotswap - Fix three edge cases that lead to a crash#27rameshvarun wants to merge 1 commit intorxi:masterfrom
rameshvarun wants to merge 1 commit intorxi:masterfrom
Conversation
rameshvarun
commented
Aug 25, 2018
| if oldmt and newmt then update(oldmt, newmt) end | ||
| for k, v in pairs(new) do | ||
| if type(v) == "table" then update(old[k], v) else old[k] = v end | ||
| if type(v) == "table" and type(old[k]) == "table" then |
Author
There was a problem hiding this comment.
If table -> value or value -> table, just do an assignment instead of an update.
rameshvarun
commented
Aug 25, 2018
| package.loaded[modname] = nil | ||
| local newmod = require(modname) | ||
| if type(oldmod) == "table" then update(oldmod, newmod) end | ||
| if type(newmod) == "table" and type(oldmod) == "table" then |
Author
There was a problem hiding this comment.
Only merge if both oldmod/newmod are both tables. This could be replaced with a check inside update but since the other call paths need to check out of update I thought consistency would be better.
rameshvarun
commented
Aug 25, 2018
| end | ||
| for k, v in pairs(oldglobal) do | ||
| if v ~= _G[k] and type(v) == "table" then | ||
| if v ~= _G[k] and type(v) == "table" and type(_G[k]) == "table" then |
Author
There was a problem hiding this comment.
Only update + replace with updated value if both old and new are tables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found three edge cases that can lead to a crash in lurker. All of these have to do with calling
updateon a non-table object. In order of how reasonable they are:return {}return {}One of these can be solved by just checking in
updateitself, but the other two require checks before callingupdate.