Bug #20322
closedrb_enc_interned_str_cstr doesn't accept null pointer for encoding
Description
The header documentation for rb_enc_interned_str_cstr
notes:
enc
can be a null pointer.
When adding support for this function to TruffleRuby we noticed that the behaviour did not match that documentation. I think this did work previously, but it currently causes a segmentation fault when trying to autoload the encoding because it calls rb_enc_mbmaxlen
which expects a non-null encoding.
I'm not sure how important this behaviour is, whether extensions ever actually call this with a null pointer, or if the documentation is instead just incorrect. I think it's a straightforward fix to make the behaviour match the documentation, so I would like to open a PR, but also happy to just remove the note if that is preferable.
Updated by byroot (Jean Boussier) 9 months ago
That's a regression and should be fixed mostly for consistency with other functions that take a encoding pointer.
Updated by thomasmarshall (Thomas Marshall) 9 months ago
I opened a PR to fix this: https://github.com/ruby/ruby/pull/10169
Updated by nobu (Nobuyoshi Nakada) 9 months ago
- Related to Bug #18772: Backport edf01d4e82d8e44ee30ec41fbcb7f802bc8b8c5d added
Updated by nobu (Nobuyoshi Nakada) 9 months ago
- Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED
Updated by thomasmarshall (Thomas Marshall) 9 months ago
- Status changed from Open to Closed
Applied in changeset git|7e4b1f8e1935a10df3c41ee60ca0987d73281126.
[Bug #20322] Fix rb_enc_interned_str_cstr null encoding
The documentation for rb_enc_interned_str_cstr
notes that enc
can be
a null pointer, but this currently causes a segmentation fault when
trying to autoload the encoding. This commit fixes the issue by checking
for NULL before calling rb_enc_autoload
.
Updated by k0kubun (Takashi Kokubun) 6 months ago
- Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE
ruby_3_3 548c7cb9f517dcb8029bd9698187c81819e08edd merged revision(s) 7e4b1f8e1935a10df3c41ee60ca0987d73281126.
Updated by nagachika (Tomoyuki Chikanaga) 5 months ago
- Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE, 3.3: DONE
ruby_3_2 a6b7aad954680e23e7db81d69a7e8e44583bf8b4 merged revision(s) 7e4b1f8e1935a10df3c41ee60ca0987d73281126.