Skip to content

Commit

Permalink
Merge pull request #372 from Maxxen/dev-stable
Browse files Browse the repository at this point in the history
Fix memory leak in st_asgeojson, avoid copy
  • Loading branch information
Maxxen authored Aug 15, 2024
2 parents e04e2f0 + 06e2db9 commit d883e28
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spatial/src/spatial/core/functions/scalar/st_asgeojson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ static void GeometryToGeoJSONFragmentFunction(DataChunk &args, ExpressionState &
Geometry::Match<ToGeoJSONFunctor>(geom, doc, obj);

size_t json_size = 0;
// TODO: YYJSON_WRITE_PRETTY
auto json_data = yyjson_mut_write(doc, 0, &json_size);
auto json_str = StringVector::AddString(result, json_data, json_size);
return json_str;
char *json_data = yyjson_mut_write_opts(doc, 0, json_allocator.GetYYJSONAllocator(), &json_size, nullptr);
// Because the arena allocator only resets after each pipeline invocation, we can safely just point into the
// arena here without needing to copy the data to the string heap with StringVector::AddString
return string_t(json_data, json_size);
});
}

Expand Down

0 comments on commit d883e28

Please sign in to comment.