Perl: better argument validation(patch from dankogai)

This commit is contained in:
tokuhirom 2010-08-31 23:42:32 +09:00
parent 71a1cb0184
commit 23a7137e6a
2 changed files with 6 additions and 3 deletions

View File

@ -151,7 +151,7 @@ static int try_int(enc_t* enc, const char *p, size_t len) {
static void _msgpack_pack_rv(enc_t *enc, SV* sv, int depth);
static void _msgpack_pack_sv(enc_t *enc, SV* sv, int depth) {
if (!depth) Perl_croak(aTHX_ ERR_NESTING_EXCEEDED);
if (depth <= 0) Perl_croak(aTHX_ ERR_NESTING_EXCEEDED);
SvGETMAGIC(sv);
if (sv==NULL) {
@ -187,7 +187,7 @@ static void _msgpack_pack_sv(enc_t *enc, SV* sv, int depth) {
static void _msgpack_pack_rv(enc_t *enc, SV* sv, int depth) {
svtype svt;
if (!depth) Perl_croak(aTHX_ ERR_NESTING_EXCEEDED);
if (depth <= 0) Perl_croak(aTHX_ ERR_NESTING_EXCEEDED);
SvGETMAGIC(sv);
svt = SvTYPE(sv);

View File

@ -2,7 +2,7 @@ use t::Util;
use Test::More;
use Data::MessagePack;
plan tests => 5;
plan tests => 6;
my $aref = [0];
$aref->[1] = $aref;
@ -23,3 +23,6 @@ ok !$@;
eval { Data::MessagePack->pack($aref, 2) };
ok $@, $@;
eval { Data::MessagePack->pack($aref, -1) };
ok $@, $@;