[svn:parrot] r46141 - in trunk: src src/pmc t/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Thu Apr 29 15:40:06 UTC 2010


Author: NotFound
Date: Thu Apr 29 15:40:06 2010
New Revision: 46141
URL: https://trac.parrot.org/parrot/changeset/46141

Log:
more packfile error checking

Modified:
   trunk/src/packfile.c
   trunk/src/pmc/packfileannotations.pmc
   trunk/t/pmc/packfileannotations.t

Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c	Thu Apr 29 14:52:22 2010	(r46140)
+++ trunk/src/packfile.c	Thu Apr 29 15:40:06 2010	(r46141)
@@ -293,9 +293,10 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static opcode_t * pf_debug_pack(SHIM_INTERP,
+static opcode_t * pf_debug_pack(PARROT_INTERP,
     ARGMOD(PackFile_Segment *self),
     ARGOUT(opcode_t *cursor))
+        __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
         FUNC_MODIFIES(*self)
@@ -454,7 +455,8 @@
 #define ASSERT_ARGS_pf_debug_new __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_pf_debug_pack __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(self) \
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(self) \
     , PARROT_ASSERT_ARG(cursor))
 #define ASSERT_ARGS_pf_debug_packed_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(self))
@@ -2701,13 +2703,17 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static opcode_t *
-pf_debug_pack(SHIM_INTERP, ARGMOD(PackFile_Segment *self), ARGOUT(opcode_t *cursor))
+pf_debug_pack(PARROT_INTERP, ARGMOD(PackFile_Segment *self), ARGOUT(opcode_t *cursor))
 {
     ASSERT_ARGS(pf_debug_pack)
     PackFile_Debug * const debug = (PackFile_Debug *)self;
     const              int n     = debug->num_mappings;
     int i;
 
+    if (n > 0 && debug->mappings == NULL)
+        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
+	    "No mappings but non zero num mappings(%I)", n);
+
     /* Store number of mappings. */
     *cursor++ = n;
 
@@ -3000,7 +3006,7 @@
     }
 
     /* Otherwise, no mappings == no filename. */
-    return string_from_literal(interp, "(unknown file)");
+    return CONST_STRING(interp, "(unknown file)");
 }
 
 

Modified: trunk/src/pmc/packfileannotations.pmc
==============================================================================
--- trunk/src/pmc/packfileannotations.pmc	Thu Apr 29 14:52:22 2010	(r46140)
+++ trunk/src/pmc/packfileannotations.pmc	Thu Apr 29 15:40:06 2010	(r46141)
@@ -229,6 +229,10 @@
             /* Poke directly to annotation attributes. */
             annotation_attrs         = PARROT_PACKFILEANNOTATION(annotation);
             annotation_attrs->offset = entry->bytecode_offset;
+            if (! attrs->const_table)
+                Parrot_ex_throw_from_c_args(interp, NULL,
+                        EXCEPTION_MALFORMED_PACKFILE, "No constant table");
+
             annotation_attrs->name   = VTABLE_get_string_keyed_int(interp,
                     attrs->const_table, key->name);
             switch (key->type) {

Modified: trunk/t/pmc/packfileannotations.t
==============================================================================
--- trunk/t/pmc/packfileannotations.t	Thu Apr 29 14:52:22 2010	(r46140)
+++ trunk/t/pmc/packfileannotations.t	Thu Apr 29 15:40:06 2010	(r46141)
@@ -42,6 +42,7 @@
 
     push_eh load_error
     $P0 = open 't/native_pbc/annotations.pbc'
+    $P0.'encoding'('binary')
     $S0 = $P0.'readall'()
     pf = new 'Packfile'
     pf = $S0
@@ -50,7 +51,7 @@
 load_error:
     .get_results($P0)
     pop_eh
-    nok(1, "PackfileAnnotations unpack failed to load test file")
+    report_load_error($P0, "PackfileAnnotations unpack failed to load test file")
     skip(7, "PackfileAnnotations unpack tests failed")
     .return()
 .end


More information about the parrot-commits mailing list