Skip to contentSkip to conversation

qobject: Fix maybe uninitialized in qdict_array_split

PATCH Superseded Janosch Frank 2 participants 4 messages May 18, 2021 – May 31, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qobject: Fix maybe uninitialized in qdict_array_split

Lets make the compiler happy.

---
 qobject/block-qdict.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qobject/block-qdict.c +1 -1
index 1487cc5dd8..b26524429c 100644
@@ -224,7 +224,7 @@ void qdict_array_split(QDict *src, QList **dst)
     for (i = 0; i < UINT_MAX; i++) {
         QObject *subqobj;
         bool is_subqdict;
-        QDict *subqdict;
+        QDict *subqdict = NULL;
         char indexstr[32], prefix[32];
         size_t snprintf_ret;
 
Signature · 1 line
2.30.2
#1 lore raw
Quoted 3 lines · Janosch Frank

Lets make the compiler happy.

Ping
My build is still breaking on Ubuntu because of this.

Quoted 18 lines
---
 qobject/block-qdict.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qobject/block-qdict.c +1 -1
index 1487cc5dd8..b26524429c 100644
@@ -224,7 +224,7 @@ void qdict_array_split(QDict *src, QList **dst)
     for (i = 0; i < UINT_MAX; i++) {
         QObject *subqobj;
         bool is_subqdict;
-        QDict *subqdict;
+        QDict *subqdict = NULL;
         char indexstr[32], prefix[32];
         size_t snprintf_ret;
 
#2 lore raw
Quoted 12 lines · Janosch Frank
Quoted 3 lines · Janosch Frank

Lets make the compiler happy.

Ping
My build is still breaking on Ubuntu because of this.

Quoted 4 lines
---
 qobject/block-qdict.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

qobject/block-qdict.c void qdict_array_split(QDict *src, QList **dst) · line 229

Quoted 12 lines
qobject/block-qdict.c +1 -1
index 1487cc5dd8..b26524429c 100644
@@ -224,7 +224,7 @@ void qdict_array_split(QDict *src, QList **dst)
     for (i = 0; i < UINT_MAX; i++) {
         QObject *subqobj;
         bool is_subqdict;
-        QDict *subqdict;
+        QDict *subqdict = NULL;
         char indexstr[32], prefix[32];
         size_t snprintf_ret;

Slightly clearer:

-- >8 --

qobject/block-qdict.c +4 -4
index 1487cc5dd8b..8d0f00bc3ce 100644
@@ -224,7 +224,6 @@ void qdict_array_split(QDict *src, QList **dst)
     for (i = 0; i < UINT_MAX; i++) {
         QObject *subqobj;
         bool is_subqdict;
-        QDict *subqdict;
         char indexstr[32], prefix[32];
         size_t snprintf_ret;
 
@@ -249,14 +248,16 @@ void qdict_array_split(QDict *src, QList **dst)
         }
 
         if (is_subqdict) {
+            QDict *subqdict = NULL;
+
             qdict_extract_subqdict(src, &subqdict, prefix);
             assert(qdict_size(subqdict) > 0);
+            qlist_append_obj(*dst, QOBJECT(subqdict));
         } else {
             qobject_ref(subqobj);
             qdict_del(src, indexstr);
+            qlist_append_obj(*dst, subqobj);
         }
-
-        qlist_append_obj(*dst, subqobj ?: QOBJECT(subqdict));
     }
 }
---

Anyhow,

Cc'ing qemu-trivial@

#3 lore raw
Quoted 49 lines · Philippe Mathieu-Daudé
Quoted 12 lines · Janosch Frank
Quoted 3 lines · Janosch Frank

Lets make the compiler happy.

Ping
My build is still breaking on Ubuntu because of this.

Quoted 4 lines
---
 qobject/block-qdict.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

qobject/block-qdict.c void qdict_array_split(QDict *src, QList **dst) · line 229

Quoted 12 lines
qobject/block-qdict.c +1 -1
index 1487cc5dd8..b26524429c 100644
@@ -224,7 +224,7 @@ void qdict_array_split(QDict *src, QList **dst)
     for (i = 0; i < UINT_MAX; i++) {
         QObject *subqobj;
         bool is_subqdict;
-        QDict *subqdict;
+        QDict *subqdict = NULL;
         char indexstr[32], prefix[32];
         size_t snprintf_ret;

Slightly clearer:>
-- >8 --

qobject/block-qdict.c +3 -1
index 1487cc5dd8b..8d0f00bc3ce 100644
@@ -224,7 +224,6 @@ void qdict_array_split(QDict *src, QList **dst)
     for (i = 0; i < UINT_MAX; i++) {
         QObject *subqobj;
         bool is_subqdict;
-        QDict *subqdict;
         char indexstr[32], prefix[32];
         size_t snprintf_ret;
 
@@ -249,14 +248,16 @@ void qdict_array_split(QDict *src, QList **dst)
         }
 
         if (is_subqdict) {
+            QDict *subqdict = NULL;
+
             qdict_extract_subqdict(src, &subqdict, prefix);
             assert(qdict_size(subqdict) > 0);
+            qlist_append_obj(*dst, QOBJECT(subqdict));

qobject/block-qdict.c void qdict_array_split(QDict *src, QList **dst) · line 262

Quoted 10 lines
qobject/block-qdict.c +1 -3
         } else {
             qobject_ref(subqobj);
             qdict_del(src, indexstr);
+            qlist_append_obj(*dst, subqobj);
         }
-
-        qlist_append_obj(*dst, subqobj ?: QOBJECT(subqdict));
     }
 }
---

If you want post that snippet yourself, go ahead.
After all I only fixed a symptom without a closer look into the code.

Quoted 6 lines

Anyhow,

Cc'ing qemu-trivial@

If not I'll take it, test on s390 and send a v2 with qemu-trivial and you in CC.

Thanks for having a look!