[issue9242] unicodeobject.c: use of uninitialized values

Stefan Krah report at bugs.python.org
Tue Jul 13 13:40:10 CEST 2010


Stefan Krah <stefan-usenet at bytereef.org> added the comment:

> const int iorder[4] = {0, 1, 2, 3};

const isn't possible, iorder is modified later on. Adding the array
dimension did not change anything.

Making everything const (see below) did not change anything either.
I presume that Valgrind regards qq[2] or qq[3] as uninitialized.


Index: Objects/unicodeobject.c
===================================================================
--- Objects/unicodeobject.c     (revision 82816)
+++ Objects/unicodeobject.c     (working copy)
@@ -2216,10 +2216,12 @@
     int bo = 0;       /* assume native ordering by default */
     const char *errmsg = "";
     /* Offsets from q for retrieving bytes in the right order. */
+    const int iorder_le[] = {0, 1, 2, 3};
+    const int iorder_be[] = {3, 2, 1, 0};
 #ifdef BYTEORDER_IS_LITTLE_ENDIAN
-    int iorder[] = {0, 1, 2, 3};
+    const int *iorder = iorder_le;
 #else
-    int iorder[] = {3, 2, 1, 0};
+    const int *iorder = iorder_be;
 #endif
     PyObject *errorHandler = NULL;
     PyObject *exc = NULL;
@@ -2262,17 +2264,11 @@
 
     if (bo == -1) {
         /* force LE */
-        iorder[0] = 0;
-        iorder[1] = 1;
-        iorder[2] = 2;
-        iorder[3] = 3;
+        iorder = iorder_le;
     }
     else if (bo == 1) {
         /* force BE */
-        iorder[0] = 3;
-        iorder[1] = 2;
-        iorder[2] = 1;
-        iorder[3] = 0;
+        iorder = iorder_be;
     }

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9242>
_______________________________________


More information about the Python-bugs-list mailing list