diff --git a/meos/src/general/type_out.c b/meos/src/general/type_out.c index ab816eb811..6d3f269545 100644 --- a/meos/src/general/type_out.c +++ b/meos/src/general/type_out.c @@ -763,9 +763,12 @@ temporal_as_mfjson(const Temporal *temp, bool with_bbox, int flags, if (flags == 0) return result; + /* Convert to JSON and back to a C string to apply flags using json-c */ struct json_object *jobj = json_tokener_parse(result); pfree(result); - return (char *) json_object_to_json_string_ext(jobj, flags); + result = strdup(json_object_to_json_string_ext(jobj, flags)); + json_object_put(jobj); + return result; } /***************************************************************************** diff --git a/meos/src/general/type_parser.c b/meos/src/general/type_parser.c index 9ffed39b94..9c5c1d4c9d 100644 --- a/meos/src/general/type_parser.c +++ b/meos/src/general/type_parser.c @@ -596,9 +596,8 @@ span_parse(const char **str, meosType spantype, bool end, Span *span) if (end && ! ensure_end_input(str, "span")) return false; - if (! span) - return true; - span_set(lower, upper, lower_inc, upper_inc, basetype, spantype, span); + if (span) + span_set(lower, upper, lower_inc, upper_inc, basetype, spantype, span); return true; } @@ -663,13 +662,16 @@ tinstant_parse(const char **str, meosType temptype, bool end, if (! temporal_basetype_parse(str, basetype, &elem)) return false; TimestampTz t = timestamp_parse(str); - if (t == DT_NOEND) - return false; - /* Ensure there is no more input */ - if (end && ! ensure_end_input(str, "temporal")) + if (t == DT_NOEND || + /* Ensure there is no more input */ + (end && ! ensure_end_input(str, "temporal"))) + { + DATUM_FREE(elem, basetype); return false; + } if (result) - *result = tinstant_make_free(elem, temptype, t); + *result = tinstant_make(elem, temptype, t); + DATUM_FREE(elem, basetype); return true; } @@ -774,8 +776,9 @@ tcontseq_parse(const char **str, meosType temptype, interpType interp, p_cbracket(str); p_cparen(str); if (result) - *result = tsequence_make_free(instants, count, lower_inc, upper_inc, - interp, NORMALIZE); + *result = tsequence_make((const TInstant **) instants, count, + lower_inc, upper_inc, interp, NORMALIZE); + pfree_array((void **) instants, count); return true; } diff --git a/meos/src/point/tpoint_parser.c b/meos/src/point/tpoint_parser.c index f55cd8b9b9..e9f2f5a7e2 100644 --- a/meos/src/point/tpoint_parser.c +++ b/meos/src/point/tpoint_parser.c @@ -38,6 +38,7 @@ #include #include #include "general/type_parser.h" +#include "general/type_util.h" #include "point/tpoint_spatialfuncs.h" /*****************************************************************************/ @@ -286,15 +287,16 @@ tpointinst_parse(const char **str, meosType temptype, bool end, return false; } TimestampTz t = timestamp_parse(str); - if (t == DT_NOEND) - return false; - if (end && ! ensure_end_input(str, "temporal point")) + if (t == DT_NOEND || + /* Ensure there is no more input */ + (end && ! ensure_end_input(str, "temporal point"))) { pfree(gs); return false; } if (result) - *result = tinstant_make_free(PointerGetDatum(gs), temptype, t); + *result = tinstant_make(PointerGetDatum(gs), temptype, t); + pfree(gs); return true; } @@ -399,8 +401,9 @@ tpointseq_cont_parse(const char **str, meosType temptype, interpType interp, p_cbracket(str); p_cparen(str); if (result) - *result = tsequence_make_free(instants, count, lower_inc, upper_inc, - interp, NORMALIZE); + *result = tsequence_make((const TInstant **) instants, count, + lower_inc, upper_inc, interp, NORMALIZE); + pfree_array((void **) instants, count); return true; }