Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent segfault with some binary characters. #10

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

bglimepoint
Copy link
Contributor

@bglimepoint bglimepoint commented Aug 8, 2023

e.g. "\xE9".

Fixes:

multi_string_replace/spec/multi_string_replace_spec.rb:131: [BUG] Segmentation fault at 0x0000000000000000
ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0031 p:---- s:0157 e:000156 CFUNC  :replace
c:0030 p:0021 s:0151 e:000149 BLOCK  /mnt/limepoint/multi_string_replace/spec/multi_string_replace_spec.rb:131 [FINISH]
c:0029 p:---- s:0147 e:000146 CFUNC  :instance_exec
...

Fixes: #9

@bglimepoint
Copy link
Contributor Author

My C isn't good enough to know the "why" of this, but it seems to fix the issue we were seeing in #9...

e.g. "\xE9".

Fixes:

```
multi_string_replace/spec/multi_string_replace_spec.rb:131: [BUG] Segmentation fault at 0x0000000000000000
ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0031 p:---- s:0157 e:000156 CFUNC  :replace
c:0030 p:0021 s:0151 e:000149 BLOCK  /mnt/limepoint/multi_string_replace/spec/multi_string_replace_spec.rb:131 [FINISH]
c:0029 p:---- s:0147 e:000146 CFUNC  :instance_exec
...
```

Upstream has this as an `unsigned char`, hence the use of it:

https://github.com/morenice/ahocorasick/blob/1914054f60e7d92ac0f0b5ae95dfd36fb00e9b6b/src/aho_trie.c#L32
@jedld jedld merged commit b29ec37 into jedld:master Aug 9, 2023
1 check 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.

Replacement fails when strings include binary characters (e.g. \xE9)
2 participants