]> granicus.if.org Git - transmission/commitdiff
(trunk libT) fix "dangerous pointer arithmetic" warning detected by clang static...
authorJordan Lee <jordan@transmissionbt.com>
Thu, 31 Mar 2011 04:24:57 +0000 (04:24 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Thu, 31 Mar 2011 04:24:57 +0000 (04:24 +0000)
libtransmission/bencode.c

index f582496f2fecb02cecb3ac6fd68f4a2d5475ef0f..2b06f84206d723929097bc1a29cdc3871a9e9dac 100644 (file)
@@ -1398,11 +1398,11 @@ jsonStringFunc( const tr_benc * val, void * vdata )
                     *outwalk++ = *it;
                 else {
                     const UTF8 * tmp = it;
-                    UTF32        buf = 0;
-                    UTF32 *      u32 = &buf;
-                    ConversionResult result = ConvertUTF8toUTF32( &tmp, end, &u32, &buf + 1, 0 );
+                    UTF32        buf[1] = { 0 };
+                    UTF32 *      u32 = buf;
+                    ConversionResult result = ConvertUTF8toUTF32( &tmp, end, &u32, buf + 1, 0 );
                     if((( result==conversionOK ) || (result==targetExhausted)) && (tmp!=it)) {
-                        outwalk += tr_snprintf( outwalk, outend-outwalk, "\\u%04x", (unsigned int)buf );
+                        outwalk += tr_snprintf( outwalk, outend-outwalk, "\\u%04x", (unsigned int)buf[0] );
                         it = tmp - 1;
                     }
                 }