Skip to content

Commit 1b4a1a9

Browse files
committed
utf8.c: convert assertion from English to C
Coverity (CID 584855) complains that _invlist_search can return negative values. There is a comment that asserts this cannot happen here. Convert that comment to a C-level assert(). I don't know if that will silence Coverity, but it can't hurt to verify the invariant at least in debugging builds. (Also, convert RT ticket ID to Github issue number and do the PERL_ARGS_ASSERT_... thing first.)
1 parent 83f6787 commit 1b4a1a9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

utf8.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4143,13 +4143,14 @@ Perl_inverse_folds_(pTHX_ const UV cp, U32 * first_folds_to,
41434143
* constructed with this size (to save space and memory), and we return
41444144
* pointers, so they must be this size */
41454145

4146+
PERL_ARGS_ASSERT_INVERSE_FOLDS_;
4147+
41464148
/* 'index' is guaranteed to be non-negative, as this is an inversion map
4147-
* that covers all possible inputs. See [perl #133365] */
4149+
* that covers all possible inputs. See [GH #16624] */
41484150
SSize_t index = _invlist_search(PL_utf8_foldclosures, cp);
4151+
assert(index >= 0);
41494152
I32 base = _Perl_IVCF_invmap[index];
41504153

4151-
PERL_ARGS_ASSERT_INVERSE_FOLDS_;
4152-
41534154
if (base == 0) { /* No fold */
41544155
*first_folds_to = 0;
41554156
*remaining_folds_to = NULL;

0 commit comments

Comments
 (0)