diff --git a/tui/include/trainlog/web_sessions.h b/tui/include/trainlog/web_sessions.h index 159688b..7489440 100644 --- a/tui/include/trainlog/web_sessions.h +++ b/tui/include/trainlog/web_sessions.h @@ -24,6 +24,12 @@ typedef struct TrainlogWebSessionsPageQuery { const char *search; } TrainlogWebSessionsPageQuery; +/* + * CONTRACT: every successful JSON-producing function below transfers one + * heap allocation through output_json; the caller owns it and releases it + * with free(). Borrowed input strings need only remain valid for the call. + */ + /* * CONTRACT: database and query strings are borrowed for the call. On success, * output_json is heap-owned by the caller and must be released with free(). diff --git a/tui/tests/test_web_sessions.c b/tui/tests/test_web_sessions.c index 46dca42..422c671 100644 --- a/tui/tests/test_web_sessions.c +++ b/tui/tests/test_web_sessions.c @@ -143,6 +143,9 @@ static bool creation_replay_revision_and_pagination(void) { &updated_size) == TRAINLOG_STATUS_OK); CHECK(updated_size > 0U); CHECK(scalar(database, "SELECT COUNT(*) FROM session_preparation_revisions") == 2); + free(detail); + detail = NULL; + detail_size = 0U; CHECK(trainlog_web_sessions_save_json(database, NULL, "",