Skip to content

Commit

Permalink
FIXED: downcase_atom/2 and upcase_atom/2: error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Oct 31, 2023
1 parent 3d24113 commit 090b621
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/os/pl-ctype.c
Expand Up @@ -576,6 +576,7 @@ modify_case_atom(DECL_LD term_t in, term_t out, int down, int text_type)
return TRUE;
} else if ( PL_is_variable(out) )
{ tmp_buffer b;
int rc;

if ( tin.encoding == ENC_ISO_LATIN_1 )
{ const unsigned char *in = (const unsigned char*)tin.text.t;
Expand Down Expand Up @@ -635,12 +636,13 @@ modify_case_atom(DECL_LD term_t in, term_t out, int down, int text_type)
tout.canonical = FALSE;
}

PL_unify_text(out, 0, &tout, text_type);
rc = PL_unify_text(out, 0, &tout, text_type);
PL_free_text(&tin);
PL_free_text(&tout);
if ( tin.encoding != ENC_ISO_LATIN_1 )
discardBuffer(&b);

succeed;
return rc;
} else
{ return PL_error(NULL, 0, NULL, ERR_TYPE,
text_type == PL_STRING ? ATOM_string : ATOM_atom,
Expand Down

1 comment on commit 090b621

@JanWielemaker
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on SWI-Prolog. There might be relevant details there:

https://swi-prolog.discourse.group/t/issue-with-processing-unicode/6931/4

Please sign in to comment.