Skip to content

Commit

Permalink
Add a comment about possible NULL pointer in string encoder
Browse files Browse the repository at this point in the history
Fixes #580
  • Loading branch information
larskanis committed Aug 11, 2024
1 parent 764f6d5 commit 64fe4c1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/pg_text_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ pg_text_enc_boolean(t_pg_coder *this, VALUE value, char *out, VALUE *intermediat
int
pg_coder_enc_to_s(t_pg_coder *this, VALUE value, char *out, VALUE *intermediate, int enc_idx)
{
/* Attention:
* In contrast to all other encoders, the "this" pointer of this encoder can be NULL.
* This is because it is used as a fall-back if no encoder is defined.
*/
VALUE str = rb_obj_as_string(value);
if( ENCODING_GET(str) == enc_idx ){
*intermediate = str;
Expand Down

0 comments on commit 64fe4c1

Please sign in to comment.