fix: missing bound check on populating context menu
Merge pull request #5517 from tamland/ctxmenusegfault