summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-10-21 21:33:03 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-10-21 21:33:20 (GMT)
commitd800cb1c80ec68eb1ad85134fd9c0727023f572a (patch)
tree6fcf08b763b9f1a7b6708918085b352abe671631
parentcff2f506464abf93c35feb6d644ad08b79feb856 (diff)
Fixed bugs as realloc() may change base addresses and does not initialize new memory.
-rw-r--r--ChangeLog6
-rw-r--r--src/glibext/gwidthtracker.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index ee1fa84..336a34b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
16-10-21 Cyrille Bagard <nocbos@gmail.com>
+ * src/glibext/gwidthtracker.c:
+ Compute again portion addresses after reallocations as their base address
+ may have changed. Do not use uninitialized value as cache status.
+
+16-10-21 Cyrille Bagard <nocbos@gmail.com>
+
* src/common/shuffle.c:
Avoid to copy overlapping memory areas.
diff --git a/src/glibext/gwidthtracker.c b/src/glibext/gwidthtracker.c
index 10d01ab..94e7f36 100644
--- a/src/glibext/gwidthtracker.c
+++ b/src/glibext/gwidthtracker.c
@@ -518,6 +518,8 @@ void g_width_tracker_update_added(GWidthTracker *tracker, size_t index, size_t c
tracker->portions = (common_metrics *)realloc(tracker->portions,
tracker->count * sizeof(common_metrics));
+ portion = &tracker->portions[current];
+
dest = current + 2;
src = current + 1;
@@ -535,6 +537,8 @@ void g_width_tracker_update_added(GWidthTracker *tracker, size_t index, size_t c
tracker->portions[current + 1].first = portion->first + 1;
tracker->portions[current + 1].last = portion->last;
+ tracker->portions[current + 1].cached = false;
+
portion->first = i;
portion->last = i;
@@ -546,6 +550,8 @@ void g_width_tracker_update_added(GWidthTracker *tracker, size_t index, size_t c
tracker->portions[current + 1].first = i;
tracker->portions[current + 1].last = portion->last;
+ tracker->portions[current + 1].cached = false;
+
portion->last = i - 1;
}