Skip to content

[24365] Fix UB in serialization methods#313

Merged
MiguelCompany merged 5 commits into
masterfrom
add_ubsan
May 19, 2026
Merged

[24365] Fix UB in serialization methods#313
MiguelCompany merged 5 commits into
masterfrom
add_ubsan

Conversation

@cferreiragonz
Copy link
Copy Markdown
Contributor

@cferreiragonz cferreiragonz commented May 18, 2026

Description

This PR fixes:

  • UB error CdrSizeCalculator.hpp:1068:87: member call on null pointer of type 'const struct array' caused by an access to data->data() when size is 0.
  • UB error Cdr.h:2976:77: runtime error: member call on null pointer of type 'const struct array' caused by an access to data->data() when size is 0.

Related PRs

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • N/A: Any new/modified methods have been properly documented using Doxygen.
  • N/A: Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • N/A: Changes are API compatible.
  • N/A: New feature has been added to the versions.md file (if applicable).
  • N/A: Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: CI pass and failing tests are unrelated with the changes.

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
@cferreiragonz cferreiragonz requested review from richiprosima and removed request for richiprosima May 19, 2026 05:55
@cferreiragonz cferreiragonz changed the title [24365] Fix UB in 'calculate_array_serialized_size' [24365] Fix UB in serialization methods May 19, 2026
@cferreiragonz cferreiragonz modified the milestones: v2.3.6, v2.4.0 May 19, 2026
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
@cferreiragonz cferreiragonz modified the milestones: v2.4.0, v2.3.6 May 19, 2026
@cferreiragonz cferreiragonz requested review from richiprosima and removed request for richiprosima May 19, 2026 07:16
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
@cferreiragonz cferreiragonz requested review from richiprosima and removed request for richiprosima May 19, 2026 07:32
@MiguelCompany MiguelCompany merged commit a9bd70c into master May 19, 2026
13 checks passed
@MiguelCompany MiguelCompany deleted the add_ubsan branch May 19, 2026 08:06
@MiguelCompany
Copy link
Copy Markdown
Member

@Mergifyio backport 2.2.x

@mergify
Copy link
Copy Markdown

mergify Bot commented May 19, 2026

backport 2.2.x

✅ Backports have been created

Details

MiguelCompany pushed a commit that referenced this pull request May 19, 2026
* Refs #24365: Fix UB in calculate_array_serialized_size



* Refs #24365: Fix UB in serialize array



* Refs #24365: Unrelated Uncrustify



* Refs #24365: Revision



* Refs #24365: Unrelated Uncrustify FastCdr.h



---------


(cherry picked from commit a9bd70c)

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
Co-authored-by: Carlos Ferreira González <carlosferreira@eprosima.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants