gentleknife / rpms / dbus

Forked from rpms/dbus 4 years ago
Clone

Blame SOURCES/avoid-undefined-7c00ed22d9b5c33f5b33221e906946b11a9bde3b.patch

e3782d
From 7c00ed22d9b5c33f5b33221e906946b11a9bde3b Mon Sep 17 00:00:00 2001
e3782d
From: DreamNik <dreamnik@mail.ru>
e3782d
Date: Sun, 29 Sep 2013 10:45:58 +0000
e3782d
Subject: make_and_run_test_nodes: avoid undefined behaviour
e3782d
e3782d
In code that looks like n[i] = v(&i), where v increments i, C leaves it
e3782d
undefined whether the old or new value of i is used to locate n[i].
e3782d
As it happens, gcc used the pre-increment value of i, but MSVC
e3782d
used the post-increment value.
e3782d
e3782d
Fix this by inserting a sequence point to disambiguate the intended order.
e3782d
e3782d
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69924
e3782d
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
e3782d
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
e3782d
[wrote commit message, fixed whitespace -smcv]
e3782d
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
e3782d
---
e3782d
diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c
e3782d
index 9512414..a2aaaf9 100644
e3782d
--- a/dbus/dbus-marshal-recursive-util.c
e3782d
+++ b/dbus/dbus-marshal-recursive-util.c
e3782d
@@ -1785,10 +1785,13 @@ make_and_run_test_nodes (void)
e3782d
   start_next_test ("All values in one big toplevel %d iteration\n", 1);
e3782d
   {
e3782d
     TestTypeNode *nodes[N_VALUES];
e3782d
+    TestTypeNode *node;
e3782d
 
e3782d
     i = 0;
e3782d
-    while ((nodes[i] = value_generator (&i)))
e3782d
-      ;
e3782d
+    while ((node = value_generator (&i)))
e3782d
+      {
e3782d
+        nodes[i - 1] = node;
e3782d
+      }
e3782d
 
e3782d
     run_test_nodes (nodes, N_VALUES);
e3782d
 
e3782d
--
e3782d
cgit v0.9.0.2-2-gbebe