Changeset 14676


Ignore:
Timestamp:
Feb 6, 2016, 10:05:22 PM (5 years ago)
Author:
mikedld
Message:

#6064: Merge ConvertUTF.c fixes from LLVM (?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ConvertUTF.c

    r14633 r14676  
    305305    case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
    306306    case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
    307     case 2: if ((a = (*--srcptr)) > 0xBF) return false;
     307    case 2: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
    308308
    309309        switch (*source) {
    310310            /* no fall-through in this inner switch */
    311311            case 0xE0: if (a < 0xA0) return false; break;
    312             case 0xED: if ((a < 0x80) || (a > 0x9F)) return false; break;
     312            case 0xED: if (a > 0x9F) return false; break;
    313313            case 0xF0: if (a < 0x90) return false; break;
    314314            case 0xF4: if (a > 0x8F) return false; break;
     
    408408        UTF32 ch = 0;
    409409        unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
    410         if (source + extraBytesToRead >= sourceEnd) {
     410        if (extraBytesToRead >= sourceEnd - source) {
    411411            result = sourceExhausted; break;
    412412        }
     
    534534        UTF32 ch = 0;
    535535        unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
    536         if (source + extraBytesToRead >= sourceEnd) {
     536        if (extraBytesToRead >= sourceEnd - source) {
    537537            result = sourceExhausted; break;
    538538        }
Note: See TracChangeset for help on using the changeset viewer.