Permalink
Browse files

Merge pull request #6 from koeppe/master

Memory leak in AnyEvent::CouchDB::Database::attach
  • Loading branch information...
2 parents 3b7bcd8 + 4ee1dc7 commit 0701a451361fcab92682640dc293f61d32ec6bda @beppu committed Nov 1, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/AnyEvent/CouchDB/Database.pm
@@ -264,6 +264,7 @@ sub remove_doc {
sub attach {
my ( $self, $doc, $attachment, $options ) = @_;
my $body < io( $options->{src} );
+ my $length = length($body);
$options->{type} ||= 'text/plain';
if ( $options->{success} ) {
my $orig = $options->{success};
@@ -275,7 +276,7 @@ sub attach {
$doc->{_attachments} ||= {};
$doc->{_attachments}->{$attachment} = {
'content_type' => $options->{type},
- 'length' => length($body),
+ 'length' => $length,
'stub' => JSON::true,
};
};
@@ -288,7 +289,7 @@ sub attach {
$doc->{_attachments} ||= {};
$doc->{_attachments}->{$attachment} = {
'content_type' => $options->{type},
- 'length' => length($body),
+ 'length' => $length,
'stub' => JSON::true,
};
};

0 comments on commit 0701a45

Please sign in to comment.