Skip to content

Commit 951ef98

Browse files
committed
[CID 16728] libfoundation: MCUnicodeGetProperty(): Incorrect overflow checks
When a signed integer is compared with an unsigned integer, it is converted to unsigned *before the comparison*. Therefore, this expression is never true: -1 < 0U
1 parent 1c194f7 commit 951ef98

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

libfoundation/src/foundation-unicode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ bool MCUnicodeGetProperty(const unichar_t *p_chars, uindex_t p_char_count, MCUni
378378
{
379379
int32_t t_prop;
380380
t_prop = MCUnicodeGetIntegerProperty(t_char, p_property);
381-
if (t_prop < UINT8_MIN || t_prop > UINT8_MAX)
381+
if (t_prop < 0 || t_prop > UINT8_MAX)
382382
return false;
383383
((uint8_t*)x_result_array)[t_offset] = uint8_t(t_prop);
384384
if (t_advance == 2)
@@ -390,7 +390,7 @@ bool MCUnicodeGetProperty(const unichar_t *p_chars, uindex_t p_char_count, MCUni
390390
{
391391
int32_t t_prop;
392392
t_prop = MCUnicodeGetIntegerProperty(t_char, p_property);
393-
if (t_prop < UINT16_MIN || t_prop > UINT16_MAX)
393+
if (t_prop < 0 || t_prop > UINT16_MAX)
394394
return false;
395395
((uint16_t*)x_result_array)[t_offset] = uint16_t(t_prop);
396396
if (t_advance == 2)
@@ -402,7 +402,7 @@ bool MCUnicodeGetProperty(const unichar_t *p_chars, uindex_t p_char_count, MCUni
402402
{
403403
int32_t t_prop;
404404
t_prop = MCUnicodeGetIntegerProperty(t_char, p_property);
405-
if (t_prop < UINT32_MIN || t_prop > UINT32_MAX)
405+
if (t_prop < 0 || t_prop > UINT32_MAX)
406406
return false;
407407
((uint32_t*)x_result_array)[t_offset] = uint32_t(t_prop);
408408
if (t_advance == 2)

0 commit comments

Comments
 (0)