Skip to content

serde_derive: Fix panic in camelCase field rename for empty names - #3055

Open
cuiweixie wants to merge 1 commit into
serde-rs:masterfrom
cuiweixie:fix/camelcase-empty-field-rename
Open

cuiweixie wants to merge 1 commit into
serde-rs:masterfrom
cuiweixie:fix/camelcase-empty-field-rename

Conversation

@cuiweixie

Copy link
Copy Markdown
Contributor

Summary

  • Guard camelCase field renaming when PascalCase yields an empty string (e.g. empty or underscore-only identifiers), avoiding an out-of-bounds slice panic.
  • Extend rename_fields unit test with an empty field name case.

Test plan

  • cargo test -p serde_derive rename_fields

When the PascalCase conversion of a field name is empty (for example an
empty identifier or a name consisting only of underscores), camelCase
rename must not index into that string. Return the original field name
instead.

Add a regression case to rename_fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant