Skip to content

Commit

Permalink
Fix an invalid SPI result use after free
Browse files Browse the repository at this point in the history
This PR fixes the invalid use of an SPI result after SPI_finish is called
and the result is freed.

(cherry picked from commit fa04a06)
  • Loading branch information
jnidzwetzki authored and timescale-automation committed Aug 31, 2023
1 parent aaa8866 commit 3e3711b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2955,10 +2955,13 @@ ts_hypertable_get_open_dim_max_value(const Hypertable *ht, int dimension_index,
if (isnull)
*isnull = max_isnull;

int64 max_value =
max_isnull ? ts_time_get_min(timetype) : ts_time_value_to_internal(maxdat, timetype);

if ((res = SPI_finish()) != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed: %s", SPI_result_code_string(res));

return max_isnull ? ts_time_get_min(timetype) : ts_time_value_to_internal(maxdat, timetype);
return max_value;
}

bool
Expand Down

0 comments on commit 3e3711b

Please sign in to comment.