Skip to content

Commit 0401b9c

Browse files
committed
utf8_to_uv_msgs: Move code to ensure initialization
There was a path through this function in which the caller's parameter it asked to be set, &msgs, did not get set. And doing it at the beginning means not needing a second place. Similarly for &errors. There is no path where it didn't get set, but it is cleaner to do it in at the same time as doing msgs.
1 parent 6a9d009 commit 0401b9c

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

utf8.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,18 +1382,20 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
13821382
* syllables that the dfa doesn't properly handle. Quickly dispose of the
13831383
* final case. */
13841384

1385+
/* Assume will be successful; override later if necessary */
1386+
if (errors) {
1387+
*errors = 0;
1388+
}
1389+
if (msgs) {
1390+
*msgs = NULL;
1391+
}
1392+
13851393
/* Each of the affected Hanguls starts with \xED */
13861394

13871395
if (is_HANGUL_ED_utf8_safe(s0, send)) { /* Always false on EBCDIC */
13881396
if (retlen) {
13891397
*retlen = 3;
13901398
}
1391-
if (errors) {
1392-
*errors = 0;
1393-
}
1394-
if (msgs) {
1395-
*msgs = NULL;
1396-
}
13971399

13981400
return ((0xED & UTF_START_MASK(3)) << (2 * UTF_ACCUMULATION_SHIFT))
13991401
| ((s0[1] & UTF_CONTINUATION_MASK) << UTF_ACCUMULATION_SHIFT)
@@ -1669,11 +1671,6 @@ Perl__utf8n_to_uvchr_msgs_helper(const U8 *s,
16691671
bool disallowed = FALSE;
16701672
const U32 orig_problems = possible_problems;
16711673

1672-
if (msgs) {
1673-
*msgs = NULL;
1674-
}
1675-
1676-
16771674
/* Returns 0 if no message needs to be generated for this problem even
16781675
* if everything else says to. Otherwise returns the warning category
16791676
* to use for the message.

0 commit comments

Comments
 (0)