Skip to content

Commit

Permalink
fix memory leak in st_asgeojson, avoid copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxxen committed Aug 15, 2024
1 parent 28ba343 commit 06e2db9
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 06e2db9

Please sign in to comment.