Skip to content

Commit

Permalink
Merge pull request #5 from afalkenhahn/patch-1
Browse files Browse the repository at this point in the history
Only call strlen() if CSA_SourceLen is not set
  • Loading branch information
jens-maus authored Feb 26, 2024
2 parents 57142d1 + c922eba commit be41483
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/codesets.c
Original file line number Diff line number Diff line change
Expand Up @@ -2452,8 +2452,10 @@ LIBPROTO(CodesetsUTF8ToStrA, STRPTR, REG(a6, UNUSED __BASE_OR_IFACE), REG(a0, st

ENTER();

if((src = (UTF8 *)GetTagData(CSA_Source, 0, attrs)) != NULL &&
(srcLen = GetTagData(CSA_SourceLen, src != NULL ? strlen((char *)src) : 0, attrs)) > 0)
src = (UTF8 *)GetTagData(CSA_Source, 0, attrs);
srcLen = FindTagItem(CSA_SourceLen, attrs) || !src ? GetTagData(CSA_SourceLen, 0, attrs) : strlen((char *)src);

if(src != NULL && srcLen > 0)
{
struct convertMsg msg;
struct codeset *codeset = NULL;
Expand Down Expand Up @@ -3257,7 +3259,9 @@ LIBPROTO(CodesetsConvertStrA, STRPTR, REG(a6, UNUSED __BASE_OR_IFACE), REG(a0, s
}
else
{
srcLen = strlen(srcStr);
if(!FindTagItem(CSA_SourceLen, attrs))
srcLen = strlen(srcStr);

charSize = sizeof(char);
}
}
Expand Down

0 comments on commit be41483

Please sign in to comment.