]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Make fill_missing_tank_pressures robust against missing cylinder info
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Aug 2012 16:05:51 +0000 (09:05 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Aug 2012 16:05:51 +0000 (09:05 -0700)
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>
profile.c

index 90ed0b6098c1a7d3d651c8cf8b7e9bf0b2b8fcb7..d3362432effe11b1e0680e9e131d6f457aa5560d 100644 (file)
--- 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