From 3b05844d760424859912d3d673dd8fc2be73d96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 15 Feb 2022 19:42:23 +0100 Subject: Fix memory bug in DlvShowEpisode. I forgot to call PL_new_term_ref for tValue. --- c/datalistview.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'c/datalistview.c') diff --git a/c/datalistview.c b/c/datalistview.c index 4a0208d..208ef22 100644 --- a/c/datalistview.c +++ b/c/datalistview.c @@ -34,8 +34,8 @@ DlvCreate(HWND hWnd) void DlvShowEpisode(int iEpisode) { + fid_t f; HWND hListView; - int r; LVITEM lviKey, lviValue; term_t t; @@ -45,14 +45,15 @@ DlvShowEpisode(int iEpisode) lviKey.mask = LVIF_TEXT; lviValue.mask = LVIF_TEXT; + f = PL_open_foreign_frame(); t = PL_new_term_refs(3); + if(!PL_put_integer(t+0, iEpisode)) return; - r = PL_call_predicate(NULL, PL_Q_NORMAL, + if (!PL_call_predicate(NULL, PL_Q_NORMAL, PL_predicate("lookup_episode_local", 3, "episode_data"), - t); - if (!r) + t)) return; /* The episode data is a list of unary compounds, @@ -78,6 +79,7 @@ DlvShowEpisode(int iEpisode) if (!szKey) continue; + tValue = PL_new_term_ref(); if (!PL_get_arg(1, tHead, tValue)) continue; if (!PL_get_atom_chars(tValue, &szValue)) @@ -106,4 +108,6 @@ DlvShowEpisode(int iEpisode) free(tszValue); } } + + PL_close_foreign_frame(f); } -- cgit v1.2.3