Registry Mirror
Skip to content

Conversation

@tannergooding

Copy link
Copy Markdown
Member

clangsharp_Cursor_getArgument and clangsharp_Cursor_getTypeParam dereference the result of ObjCCategoryDecl::getTypeParamList / ObjCInterfaceDecl::getTypeParamList via ->size() without a null check. These accessors return null for an ObjC category/interface that has no type-parameter list, so this is a latent null dereference.

The sibling clangsharp_Cursor_getNumTypeParams already guards the same accessor with a null check, so this is just a same-operation-implemented-two-ways inconsistency. This makes all three unchecked sites match that existing pattern (if (typeParamList != nullptr && i < typeParamList->size())).

Fixed sites in sources/libClangSharp/ClangSharp.cpp:

  • clangsharp_Cursor_getArgument (ObjCCategoryDecl)
  • clangsharp_Cursor_getTypeParam (ObjCCategoryDecl)
  • clangsharp_Cursor_getTypeParam (ObjCInterfaceDecl)

Native-only change; no C# or generated files touched. Verified by inspection against the existing null-checked sibling code -- a full native build/test was not run locally as it requires the complete LLVM/Clang toolchain.

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

…t and type-param APIs

ObjCCategoryDecl::getTypeParamList and ObjCInterfaceDecl::getTypeParamList can return null for declarations without a type-parameter list. clangsharp_Cursor_getArgument and clangsharp_Cursor_getTypeParam dereferenced the result via ->size() without a null check, unlike the sibling clangsharp_Cursor_getNumTypeParams which already guards it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant