Skip to content

Commit

Permalink
Merge pull request #3192 from ruby/invalid-read
Browse files Browse the repository at this point in the history
Only read from buffer if `size` is greater than 0
  • Loading branch information
kddnewton authored Oct 28, 2024
2 parents 5e39441 + 2031b62 commit 96e4777
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/pm_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pm_strspn_number_kind_underscores(const uint8_t *string, ptrdiff_t length, const
size++;
}

if (string[size - 1] == '_') *invalid = string + size - 1;
if (size > 0 && string[size - 1] == '_') *invalid = string + size - 1;
return size;
}

Expand Down

0 comments on commit 96e4777

Please sign in to comment.