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 31, 2023
1 parent e343778 commit fa04a06
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 @@ -2974,10 +2974,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 fa04a06

Please sign in to comment.