-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.3.5
-
Component/s: libbson
-
Environment:ubuntu 14.04
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Following code throws an assertion, when i == 1023:
Writer.c
#include <stdio.h> #include <bson.h> #include <assert.h> int main (int argc, char *argv[]) { bson_writer_t *writer; bson_t *doc; uint8_t *buf = NULL; size_t buflen = 0; bool r; int i; const uint32_t LENGTH = 1 << 20; uint8_t *buffer = (uint8_t *) calloc(LENGTH, sizeof(uint8_t)); writer = bson_writer_new (&buf, &buflen, 0, bson_realloc_ctx, NULL); for (i = 0; i < 10000; i++) { r = bson_writer_begin (writer, &doc); assert (r); r = BSON_APPEND_INT32 (doc, "count", i); r = bson_append_binary(doc, "data", -1, BSON_SUBTYPE_BINARY, buffer, LENGTH); assert (r); bson_writer_end (writer); } bson_free (buf); return 0; }