mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-03-29 20:32:12 +02:00
* PHPC-2211: Free intermediary result in php_phongo_bson_to_json() This was responsible for several memory leaks in MongoDB\BSON\Document's JSON output methods. * PHPC-2210: Fix direct copying of Document and PackedArray BSON bson_copy_to() cannot be used with a bson_t originally allocated with bson_new(), since there is no way to revert the bson_t to an uninitialized state. The previous code with bson_destroy() resulted in invalid reads/writes (reported by Valgrind) and could cause "malloc(): unaligned tcache chunk detected" aborts later in the process during a future, unrelated call to bson_copy_to(). With bson_destroy() removed, the malloc() aborts are avoided but Valgrind reports a leak for the originally allocation by bson_new(). The solution applied here borrows logic from bson_copy_to_excluding_noinit() to do a more flexible copy. bson_copy_to_excluding_noinit() could not be used directly because it requires at least one exclusion field name. * Run clang-format Co-authored-by: Andreas Braun <git@alcaeus.org>