]> granicus.if.org Git - python/commitdiff
unicodedata_decomposition(): sprintf -> PyOS_snprintf.
authorTim Peters <tim.peters@gmail.com>
Fri, 30 Nov 2001 07:23:05 +0000 (07:23 +0000)
committerTim Peters <tim.peters@gmail.com>
Fri, 30 Nov 2001 07:23:05 +0000 (07:23 +0000)
Modules/unicodedata.c

index 4711123eb2e1f4ea90c07f46d3b78908f0d5ca19..36c96e4a633849acfb44f26c270fbdc0d00c4440 100644 (file)
@@ -227,7 +227,7 @@ unicodedata_decomposition(PyObject *self, PyObject *args)
                              (code&((1<<DECOMP_SHIFT)-1))];
     }
 
-    /* high byte is of hex bytes (usually one or two), low byte
+    /* high byte is number of hex bytes (usually one or two), low byte
        is prefix code (from*/
     count = decomp_data[index] >> 8;
 
@@ -241,7 +241,9 @@ unicodedata_decomposition(PyObject *self, PyObject *args)
     while (count-- > 0) {
         if (i)
             decomp[i++] = ' ';
-        sprintf(decomp + i, "%04X", decomp_data[++index]);
+        assert((size_t)i < sizeof(decomp));
+        PyOS_snprintf(decomp + i, sizeof(decomp) - i, "%04X",
+                      decomp_data[++index]);
         i += strlen(decomp + i);
     }