ao-postflight: fix sloppy gps sat data realloc code (was crashing).
authorKeith Packard <keithp@keithp.com>
Sun, 15 Nov 2009 00:35:12 +0000 (16:35 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 15 Nov 2009 00:35:12 +0000 (16:35 -0800)
Realloc'ing the wrong data, and failing to set the realloc'ed size was
causing ao-postflight to crash while reading long logs.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/lib/cc-logfile.c

index 2136eec4d428cde3d077cb9a0c407259111af63d..3d346bccd3faa326a15793a6f53112810c0aaef2 100644 (file)
@@ -101,11 +101,12 @@ gpssat_add(struct cc_gpsdata *data, struct cc_gpssat *sat)
                        if (data->sizesats == 0)
                                newsats = malloc((newsizesats = 256) * sizeof (struct cc_gpssats));
                        else
-                               newsats = realloc (data->data, (newsizesats = data->sizesats * 2)
+                               newsats = realloc (data->sats, (newsizesats = data->sizesats * 2)
                                                   * sizeof (struct cc_gpssats));
                        if (!newsats)
                                return 0;
                        data->sats = newsats;
+                       data->sizesats = newsizesats;
                }
                i = data->numsats++;
                data->sats[i].nsat = 0;