fix: add null checks for std::get_if<EncodableMap> call sites#241
Open
aki1770-del wants to merge 1 commit into
Open
fix: add null checks for std::get_if<EncodableMap> call sites#241aki1770-del wants to merge 1 commit into
aki1770-del wants to merge 1 commit into
Conversation
std::get_if returns nullptr when the argument type does not match the requested variant alternative. Dereferencing the nullptr causes undefined behavior. Add an explicit null check with result->Error() before every dereference across 6 plugins (secure_storage, camera, audioplayers_linux, nav_render_view, pdf, desktop_window_linux). Fixes: toyota-connected#226 Signed-off-by: Akihiro Komada <aki1770@gmail.com>
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.
Problem
std::get_if<EncodableMap>()returnsnullptrwhen the Flutter method call argument is not anEncodableMap(e.g., wrong type or missing arguments). All affected call sites dereference the pointer unconditionally with*args, which is undefined behavior and causes an IVI HMI crash.Fixes: #226
Changes
Added an explicit null check with
result->Error()before every*argsdereference across 6 plugins:messages.ccmessages.ccmessages.ccnav_render_texture.ccmessages.ccmessages.ccTotal: 18 call sites guarded.
Fix pattern
Verification
desktop_window_linuxusesreturn std::nulloptto match the surrounding lambda return typeSigned-off-by: Akihiro Komada aki1770@gmail.com