summaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-18 19:13:59 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-18 19:13:59 -0400
commit744b4e0c1c8cab32c51db3bd1e5f5df84eaf8ad2 (patch)
treeca4f5cb0bdcb4124ec50f5ba004421d54b18774c /divelist.c
parent7226a48a8cff5637b865b64e39a6a937c20e7677 (diff)
downloadsubsurface-744b4e0c1c8cab32c51db3bd1e5f5df84eaf8ad2.tar.gz
Prevent dive_from_path from dereferencing invalid iter
This fixes a bug that Lubomir reported in a different way from the patch that he providede; I believe this to be more generic. Reported-by: "Lubomir I. Ivanov" <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/divelist.c b/divelist.c
index aedcdf03e..fb076a81b 100644
--- a/divelist.c
+++ b/divelist.c
@@ -166,9 +166,12 @@ static struct dive *dive_from_path(GtkTreePath *path)
GtkTreeIter iter;
int idx;
- gtk_tree_model_get_iter(MODEL(dive_list), &iter, path);
- gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);
- return get_dive(idx);
+ if (gtk_tree_model_get_iter(MODEL(dive_list), &iter, path)) {
+ gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);
+ return get_dive(idx);
+ } else {
+ return NULL;
+ }
}