diff options
author | K. \"pestophagous\" Heller <pestophagous@gmail.com> | 2015-12-03 22:10:03 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-12-03 22:56:54 -0800 |
commit | 445dbe73bfcc1675cdbf532752bc2b8a682dc37c (patch) | |
tree | f367086a8a7179ac0681ea01d1b361dfaf19a3a9 /subsurface-core | |
parent | 2778470b9755af2349a70f127e208750afda7725 (diff) | |
download | subsurface-445dbe73bfcc1675cdbf532752bc2b8a682dc37c.tar.gz |
Crash fix in add_single_dive. No writing to dive_table.dives[-1]
Signed-off-by: K. Heller <pestophagous@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core')
-rw-r--r-- | subsurface-core/divelist.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/subsurface-core/divelist.c b/subsurface-core/divelist.c index a14fabf88..a2e94c067 100644 --- a/subsurface-core/divelist.c +++ b/subsurface-core/divelist.c @@ -790,6 +790,9 @@ void add_single_dive(int idx, struct dive *dive) dive_table.nr++; if (dive->selected) amount_selected++; + if (idx < 0) + // convert an idx of -1 so we do insert-at-end: + idx = dive_table.nr - 1; for (i = idx; i < dive_table.nr; i++) { struct dive *tmp = dive_table.dives[i]; dive_table.dives[i] = dive; |