Skip to content

Commit 4645aa0

Browse files
authored
Merge pull request #3206 from seanm/UBSAN-NULL
Fixed UBSan warnings about offsetting a NULL pointer
2 parents dd22155 + 193cf06 commit 4645aa0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libdispatch/utf8proc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ static nc_utf8proc_ssize_t nc_seqindex_write_char_decomposed(nc_utf8proc_uint16_
388388
for (; len >= 0; entry++, len--) {
389389
nc_utf8proc_int32_t entry_cp = nc_seqindex_decode_entry(&entry);
390390

391-
written += nc_utf8proc_decompose_char(entry_cp, dst+written,
391+
nc_utf8proc_int32_t *dest = NULL;
392+
if (dst) dest = dst + written;
393+
written += nc_utf8proc_decompose_char(entry_cp, dest,
392394
(bufsize > written) ? (bufsize - written) : 0, options,
393395
last_boundclass);
394396
if (written < 0) return UTF8PROC_ERROR_OVERFLOW;
@@ -573,8 +575,10 @@ nc_utf8proc_ssize_t nc_utf8proc_decompose_custom(
573575
if (custom_func != NULL) {
574576
uc = custom_func(uc, custom_data); /* user-specified custom mapping */
575577
}
578+
nc_utf8proc_int32_t *dest = NULL;
579+
if (buffer) dest = buffer + wpos;
576580
decomp_result = nc_utf8proc_decompose_char(
577-
uc, buffer + wpos, (bufsize > wpos) ? (bufsize - wpos) : 0, options,
581+
uc, dest, (bufsize > wpos) ? (bufsize - wpos) : 0, options,
578582
&boundclass
579583
);
580584
if (decomp_result < 0) return decomp_result;

0 commit comments

Comments
 (0)