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

NotFound at svn.parrot.org NotFound at svn.parrot.org
Sun Sep 12 12:21:28 UTC 2010


Author: NotFound
Date: Sun Sep 12 12:21:27 2010
New Revision: 48954
URL: https://trac.parrot.org/parrot/changeset/48954

Log:
fix getting string from uninitialized ByteBuffer and a add a test for it, tadzik++ for the catch

Modified:
   trunk/src/pmc/bytebuffer.pmc
   trunk/t/pmc/bytebuffer.t

Modified: trunk/src/pmc/bytebuffer.pmc
==============================================================================
--- trunk/src/pmc/bytebuffer.pmc	Sun Sep 12 11:56:52 2010	(r48953)
+++ trunk/src/pmc/bytebuffer.pmc	Sun Sep 12 12:21:27 2010	(r48954)
@@ -21,16 +21,14 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING * build_string(PARROT_INTERP,
-    ARGIN(const unsigned char *content),
+    ARGIN_NULLOK(const unsigned char *content),
     INTVAL size,
     ARGIN_NULLOK(const STR_VTABLE *encoding))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(1);
 
 static INTVAL grow_to(INTVAL position);
 #define ASSERT_ARGS_build_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(content))
+       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_grow_to __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: static */
@@ -388,7 +386,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING *
-build_string(PARROT_INTERP, ARGIN(const unsigned char *content),
+build_string(PARROT_INTERP, ARGIN_NULLOK(const unsigned char *content),
         INTVAL size,
         ARGIN_NULLOK(const STR_VTABLE *encoding))
 {

Modified: trunk/t/pmc/bytebuffer.t
==============================================================================
--- trunk/t/pmc/bytebuffer.t	Sun Sep 12 11:56:52 2010	(r48953)
+++ trunk/t/pmc/bytebuffer.t	Sun Sep 12 12:21:27 2010	(r48954)
@@ -22,7 +22,7 @@
 
 .sub 'main' :main
     .include 'test_more.pir'
-    plan(37)
+    plan(38)
 
     test_init()
     test_set_string()
@@ -134,6 +134,10 @@
     .local int big
 
     bb = new ['ByteBuffer']
+    s = bb.'get_string'('ascii')
+    n = length s
+    is(s, 0, "getting from unitialized buffer gives empty string")
+
     bb = binary:"abcd"
     s = bb.'get_string'('ascii')
     n = length s


More information about the parrot-commits mailing list