summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-08-18 09:05:51 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-08-18 09:05:51 -0700
commit52c3d11d2c2a0415bf501abff6c9f99b6a7f2cce (patch)
treee35a28af90db1d0b710bed341a84b9a1aa13b833 /profile.c
parent1a05f34ae89d35f6ece12dba7b6ab5f60df98705 (diff)
downloadsubsurface-52c3d11d2c2a0415bf501abff6c9f99b6a7f2cce.tar.gz
Make fill_missing_tank_pressures robust against missing cylinder info
The code iterates over a list that can be NULL, but happily dereferenced it anyway. Oops. This function really should be split up and commented more. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/profile.c b/profile.c
index 90ed0b609..d3362432e 100644
--- a/profile.c
+++ b/profile.c
@@ -1049,16 +1049,18 @@ static void fill_missing_tank_pressures(struct plot_info *pi, pr_track_t **track
/* there may be multiple segments - so
* let's assemble the length */
nlist = list;
- pt = list->pressure_time;
- while (!nlist->end) {
- nlist = nlist->next;
- if (!nlist) {
- /* oops - we have no end pressure,
- * so this means this is a tank without
- * gas consumption information */
- break;
+ if (list) {
+ pt = list->pressure_time;
+ while (!nlist->end) {
+ nlist = nlist->next;
+ if (!nlist) {
+ /* oops - we have no end pressure,
+ * so this means this is a tank without
+ * gas consumption information */
+ break;
+ }
+ pt += nlist->pressure_time;
}
- pt += nlist->pressure_time;
}
if (!nlist) {
/* just continue without calculating