]> granicus.if.org Git - python/commitdiff
cjkcodecs: Fix compiler warning (GH-10651)
authorVictor Stinner <vstinner@redhat.com>
Thu, 22 Nov 2018 09:25:46 +0000 (10:25 +0100)
committerGitHub <noreply@github.com>
Thu, 22 Nov 2018 09:25:46 +0000 (10:25 +0100)
Fixed the following compiler warning in multibytecodec.c:

    warning C4244: '=': conversion from 'Py_ssize_t'
    to 'unsigned char', possible loss of data

Cast Py_ssize_t to unsigned char: the maximum value is checked
on the previous line.

Modules/cjkcodecs/multibytecodec.c

index 9409456c0d2749fdacba9b34d84ef4f9d1df81a6..8a0ac870f15efbdb020e97e560ecb4f0efa1049c 100644 (file)
@@ -923,8 +923,8 @@ _multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEn
             PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
             return NULL;
         }
-        statebytes[0] = pendingsize;
-        memcpy(statebytes+1, pendingbuffer, pendingsize);
+        statebytes[0] = (unsigned char)pendingsize;
+        memcpy(statebytes + 1, pendingbuffer, pendingsize);
         statesize = 1 + pendingsize;
     } else {
         statebytes[0] = 0;