Skip to content

Commit f4cf403

Browse files
authored
Merge pull request #9 from gwenn/icu-fix
Fix out of memory error on empty input
2 parents 7db035d + 628b9f2 commit f4cf403

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

icu_replace.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ static void icuReplaceAllFunc(
9494
}
9595
/* Expect output length = input length. */
9696
nOut = sqlite3_value_bytes16(argv[1]);
97+
if( nOut==0 ){ // or output length = replacement length
98+
nOut = sqlite3_value_bytes16(argv[2]);
99+
}
100+
if( nOut==0 ){ // if both input and replacement are empty
101+
sqlite3_result_text16(context, "", 0, SQLITE_STATIC);
102+
return;
103+
}
97104
/*
98105
int32_t uregex_replaceAll (URegularExpression *regexp, const UChar *replacementText, int32_t replacementLength, UChar *destBuf, int32_t destCapacity, UErrorCode *status)
99106
*/

0 commit comments

Comments
 (0)