Permalink
Browse files

fix memory problem.

bson data needs to be copied when bson objects are created.
  • Loading branch information...
1 parent 377ea08 commit 16a04dd5e6e5f7acf0402e65a1da4235c3ac1636 Tim Burks committed Dec 8, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 objc/NuBSON.m
View
@@ -224,9 +224,11 @@ - (NuBSON *) initWithBSON:(bson) b
- (NuBSON *) initWithData:(NSData *) data
{
+ bson bsonBuffer;
+ bsonBuffer.data = (char *) [data bytes];
+ bsonBuffer.owned = NO;
bson bsonValue;
- bsonValue.data = (char *) [data bytes];
- bsonValue.owned = NO;
+ bson_copy(&bsonValue, &bsonBuffer);
return [[NuBSON alloc] initWithBSON:bsonValue];
}

0 comments on commit 16a04dd

Please sign in to comment.