From: Keith Packard Date: Sun, 15 Nov 2009 00:35:12 +0000 (-0800) Subject: ao-postflight: fix sloppy gps sat data realloc code (was crashing). X-Git-Tag: debian/0.6+27+gb0d7e3f~9 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=03092d1a72a9651711e22c58dca6d6aba5705c5e ao-postflight: fix sloppy gps sat data realloc code (was crashing). 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 --- diff --git a/ao-tools/lib/cc-logfile.c b/ao-tools/lib/cc-logfile.c index 2136eec4..3d346bcc 100644 --- a/ao-tools/lib/cc-logfile.c +++ b/ao-tools/lib/cc-logfile.c @@ -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;