From: rkinyon@cpan.org Date: Sat, 28 Jun 2008 04:10:24 +0000 (+0000) Subject: Added further assertions X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=14bbb1e8687d2d9530b3cad77cf10054ef6beb7b;p=dbsrgits%2FDBM-Deep.git Added further assertions git-svn-id: http://svn.ali.as/cpan/trunk/DBM-Deep@3648 88f4d9cd-8a04-0410-9d60-8f63309c3137 --- diff --git a/lib/DBM/Deep/Engine/Sector.pm b/lib/DBM/Deep/Engine/Sector.pm index c997ec7..d86c7a5 100644 --- a/lib/DBM/Deep/Engine/Sector.pm +++ b/lib/DBM/Deep/Engine/Sector.pm @@ -51,9 +51,12 @@ sub read { my $self = shift; if ( @_ == 1 ) { + die "read(): Start ($_[0]) is too large" if $_[0] > $self->size; return substr( ${$self->engine->get_data( $self->offset, $self->size )}, $_[0] ); } elsif ( @_ == 2 ) { + die "read(): Start ($_[0]) is too large" if $_[0] > $self->size; + die "read(): Length ($_[1]) is too large" if $_[1] > $self->size; return substr( ${$self->engine->get_data( $self->offset, $self->size )}, $_[0], $_[1] ); } elsif ( @_ < 1 ) { @@ -68,6 +71,8 @@ sub write { my $self = shift; my ($start, $text) = @_; + die "write(): Start ($start) is too large" if $start > $self->size; + die "write(): length(\$text) (@{[length($text)]}) is too large" if length($text) > $self->size; substr( ${$self->engine->get_data( $self->offset, $self->size )}, $start, length($text) ) = $text; $self->mark_dirty;