[svn:parrot] r48290 - in trunk: include/parrot src/packfile src/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Tue Aug 3 17:22:12 UTC 2010


Author: chromatic
Date: Tue Aug  3 17:22:11 2010
New Revision: 48290
URL: https://trac.parrot.org/parrot/changeset/48290

Log:
[pf] Forbade null packfiles in PF_fetch_integer().

Only ImageIO calls this function, and if its packfile is NULL, there's a bigger
problem.  This commit improves Rakudo startup modestly.

Modified:
   trunk/include/parrot/packfile.h
   trunk/src/packfile/pf_items.c
   trunk/src/pmc/imageio.pmc

Modified: trunk/include/parrot/packfile.h
==============================================================================
--- trunk/include/parrot/packfile.h	Tue Aug  3 16:41:05 2010	(r48289)
+++ trunk/include/parrot/packfile.h	Tue Aug  3 17:22:11 2010	(r48290)
@@ -1048,9 +1048,8 @@
         __attribute__nonnull__(3);
 
 PARROT_WARN_UNUSED_RESULT
-INTVAL PF_fetch_integer(
-    ARGIN_NULLOK(PackFile *pf),
-    ARGIN(const opcode_t **stream))
+INTVAL PF_fetch_integer(ARGIN(PackFile *pf), ARGIN(const opcode_t **stream))
+        __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
@@ -1138,7 +1137,8 @@
     , PARROT_ASSERT_ARG(pf) \
     , PARROT_ASSERT_ARG(cursor))
 #define ASSERT_ARGS_PF_fetch_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(stream))
+       PARROT_ASSERT_ARG(pf) \
+    , PARROT_ASSERT_ARG(stream))
 #define ASSERT_ARGS_PF_fetch_number __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(stream))
 #define ASSERT_ARGS_PF_fetch_opcode __attribute__unused__ int _ASSERT_ARGS_CHECK = (\

Modified: trunk/src/packfile/pf_items.c
==============================================================================
--- trunk/src/packfile/pf_items.c	Tue Aug  3 16:41:05 2010	(r48289)
+++ trunk/src/packfile/pf_items.c	Tue Aug  3 17:22:11 2010	(r48290)
@@ -1018,20 +1018,18 @@
 XXX assumes C<sizeof (INTVAL) == sizeof (opcode_t)> - we don't have
 C<INTVAL> size in the PackFile header.
 
-When used for freeze/thaw the C<pf> argument might be NULL.
-
 =cut
 
 */
 
 PARROT_WARN_UNUSED_RESULT
 INTVAL
-PF_fetch_integer(ARGIN_NULLOK(PackFile *pf), ARGIN(const opcode_t **stream))
+PF_fetch_integer(ARGIN(PackFile *pf), ARGIN(const opcode_t **stream))
 {
     ASSERT_ARGS(PF_fetch_integer)
     INTVAL i;
 
-    if (!pf || pf->fetch_iv == NULL)
+    if (!pf->fetch_iv)
         return *(*stream)++;
     i = (pf->fetch_iv)(*((const unsigned char **)stream));
     TRACE_PRINTF_VAL(("  PF_fetch_integer: 0x%x (%d) at 0x%x\n", i, i,

Modified: trunk/src/pmc/imageio.pmc
==============================================================================
--- trunk/src/pmc/imageio.pmc	Tue Aug  3 16:41:05 2010	(r48289)
+++ trunk/src/pmc/imageio.pmc	Tue Aug  3 17:22:11 2010	(r48290)
@@ -601,10 +601,11 @@
 
 */
 
-    VTABLE INTVAL shift_integer()
-    {
+    VTABLE INTVAL shift_integer() {
         const opcode_t *pos = GET_VISIT_CURSOR(SELF);
-        INTVAL    i   = PF_fetch_integer(PARROT_IMAGEIO(SELF)->pf, &pos);
+        /* something is likely wrong if the packfile is NULL */
+        const INTVAL    i   = PF_fetch_integer(PARROT_IMAGEIO(SELF)->pf,
+                                (const opcode_t **)&pos);
         SET_VISIT_CURSOR(SELF, (char *)pos);
         BYTECODE_SHIFT_OK(SELF);
         return i;


More information about the parrot-commits mailing list