[svn:parrot] r42249 - trunk/src/string

chromatic at svn.parrot.org chromatic at svn.parrot.org
Tue Nov 3 22:35:39 UTC 2009


Author: chromatic
Date: Tue Nov  3 22:35:34 2009
New Revision: 42249
URL: https://trac.parrot.org/parrot/changeset/42249

Log:
[string] Avoided dereferencing an uninitialized pointer in
Parrot_str_unescape().

Modified:
   trunk/src/string/api.c

Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c	Tue Nov  3 21:12:18 2009	(r42248)
+++ trunk/src/string/api.c	Tue Nov  3 22:35:34 2009	(r42249)
@@ -2780,8 +2780,8 @@
     ASSERT_ARGS(Parrot_str_unescape)
 
     STRING         *result;
-    const ENCODING *encoding;
     const CHARSET  *charset;
+    const ENCODING *encoding = NULL;
 
     /* the default encoding is ascii */
     const char     *enc_name = enc_char ? enc_char : "ascii";
@@ -2801,13 +2801,14 @@
 
     if (p) {
         #define MAX_ENCODING_NAME_ALLOWED 63
-        char buffer[MAX_ENCODING_NAME_ALLOWED + 1];
-        size_t l= p - enc_char;
-        charset = NULL;
+        char   buffer[MAX_ENCODING_NAME_ALLOWED + 1];
+        size_t l = p - enc_char;
+        charset  = NULL;
+
         if (l < MAX_ENCODING_NAME_ALLOWED) {
             memcpy(buffer, enc_char, l);
-            buffer[l]= '\0';
-            encoding = Parrot_find_encoding(interp, buffer);
+            buffer[l] = '\0';
+            encoding  = Parrot_find_encoding(interp, buffer);
         }
         if (!encoding)
             Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,


More information about the parrot-commits mailing list