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.
  • Loading branch information
jnidzwetzki committed Aug 30, 2023
1 parent 3b6dc7d commit 09f7340
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2974,10 +2974,12 @@ 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 09f7340

Please sign in to comment.