Repository navigation
Fix SetMenuColumnHeader not reaching players and out-of-bounds menu column access - #1290
Open
GuiBoneVowt wants to merge 2 commits into
Open
GuiBoneVowt wants to merge 2 commits into
GuiBoneVowt wants to merge 2 commits into
Conversation
setColumnHeader was the only menu setter that did not reset initedFor_, so players that had already been sent the menu kept seeing the old header.
The column checks were "column > columnCount", so column 2 got through on a 2-column menu: setColumnHeader, addCell and getRowCount threw from .at(2), and getColumnHeader and getCell read past columnHeaders and columnMenuItems. Keep the old rule and also stay inside the arrays.
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.
Fixes #811
Two small fixes in
Server/Components/Menus/menu.hpp, one commit each:SetMenuColumnHeaderdid not update the menu for players who had already seen it.setColumnHeaderwas the only setter that did not resetinitedFor_(addCell,disableRowanddisabledo), so the nextShowMenuForPlayerdid not resend the menu and the client kept the old header.column > columnCount, socolumn = 2got through on a 2-column menu:setColumnHeader,addCellandgetRowCountthrew from.at(2)(logged as a native exception), andgetColumnHeader/getCellusedoperator[]and read past the arrays. The newisValidColumnkeeps the old rule (column <= columnCount) and also stays inside the 2-element arrays, so valid calls behave as before, including column 1 on a 1-column menu.Testing
Windows, RelWithDebInfo, Win32 + ClangCL, on top of current
master(72bf89c).Headless gamemode, 2-column menu where column 0 row 0 holds a 15-character item:
AddMenuItem(menu, 2, ...)invalid array<T, N> subscript, returns 0SetMenuColumnHeader(menu, 2, ...)GetMenuItems(menu, 2)GetMenuColumnHeader(menu, 2, ...)"\1\1NC0123456789ABCDE": the item counts, padding and the text of cell 0/0""GetMenuItem(menu, 2, 0, ...)""(also an out-of-bounds read)""In game (SA-MP 0.3.7-R5 client), the same menu shown three times, 6 seconds apart, changing both headers with
SetMenuColumnHeaderbefore eachShowMenuForPlayer:master: the menu keeps showingHEADER V1/COL2 V1on all three steps (tried three times).In-game repro (core of the gamemode)
clang-format 13 with the repo's
.clang-format: no changes.Notes
SetMenuColumnHeaderstill returnstruefor an invalid column, becauseIMenu::setColumnHeaderreturnsvoidand changing that touches the SDK.column >= columnCount) would be a one-line change inisValidColumn, but it changes whatAddMenuItemreturns for scripts that do that today, so I kept the current behaviour. Happy to change it if you prefer.