Skip to content

source: fix mapStringObject clone to copy len and keys#168

Merged
flouthoc merged 5 commits intocontainers:mainfrom
giuseppe:fix-map-string
Jan 17, 2026
Merged

source: fix mapStringObject clone to copy len and keys#168
flouthoc merged 5 commits intocontainers:mainfrom
giuseppe:fix-map-string

Conversation

@giuseppe
Copy link
Member

The emit_clone_body() method for MapStringObjectType was generating incomplete clone functions that only copied the values array but forgot to copy the len field and the keys array. This caused cloned structures to have len=0 and NULL keys, resulting in data loss when serializing and potential memory issues.

Add a test that verifies cloning of mapStringObject types (netDevices) works correctly, including proper copying of len, keys, and values.

@giuseppe
Copy link
Member Author

@flouthoc PTAL

@giuseppe giuseppe marked this pull request as draft January 14, 2026 10:47
@giuseppe
Copy link
Member Author

tests are still failing on s390x... looking into it

giuseppe and others added 5 commits January 14, 2026 12:37
The emit_clone_body() method for MapStringObjectType was generating
incomplete clone functions that only copied the values array but forgot
to copy the len field and the keys array. This caused cloned structures
to have len=0 and NULL keys, resulting in data loss when serializing
and potential memory issues.

Add a test that verifies cloning of mapStringObject types (netDevices)
works correctly, including proper copying of len, keys, and values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Fix typo 'itmes' -> 'items' in the generated C code for nested byte
array parsing. This would cause a compilation error if any schema
used nested byte arrays.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Fix invalid C syntax 'else ()' -> 'else' in two locations where
byte array generation code is emitted. This would cause compilation
errors if any schema used nested byte arrays.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Add the missing emit_clone() method to BasicMapArrayHandler so that
arrays of basic map types (mapStringString, mapStringInt, etc.) are
properly cloned. Without this, cloning would produce incomplete
results for any schema using arrays of basic maps.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Fix several issues in the nested byte array parsing code:
- Add missing assignment of _len field for the array length
- Fix NULL check to check the array pointer, not an element with
  uninitialized index variable
- Use the stored _len field instead of re-reading from YAJL
- Fix brace escaping for f-string compatibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe
Copy link
Member Author

tests are still failing on s390x... looking into it

fixed

@giuseppe giuseppe marked this pull request as ready for review January 14, 2026 13:37
Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flouthoc flouthoc merged commit 8b07b61 into containers:main Jan 17, 2026
6 checks passed
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.

2 participants