Blob Blame History Raw
From 84c6aeef5ca89c0686ae2a9ed90504010f8fe9e6 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Mon, 31 Aug 2020 14:25:56 +0200
Subject: [PATCH 28/32] topology: fix sort_config()

The temporary config array must be initialized for all compound types.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
 src/topology/save.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/topology/save.c b/src/topology/save.c
index 16fd694638ef..631d84b273bf 100644
--- a/src/topology/save.c
+++ b/src/topology/save.c
@@ -143,7 +143,6 @@ static snd_config_t *sort_config(const char *id, snd_config_t *src)
 	int index, array, count;
 
 	if (snd_config_get_type(src) != SND_CONFIG_TYPE_COMPOUND) {
-
 		if (snd_config_copy(&dst, src) >= 0)
 			return dst;
 		return NULL;
@@ -155,14 +154,13 @@ static snd_config_t *sort_config(const char *id, snd_config_t *src)
 	if (a == NULL)
 		return NULL;
 	array = snd_config_is_array(src);
-	if (array <= 0) {
-		index = 0;
-		snd_config_for_each(i, next, src) {
-			snd_config_t *s = snd_config_iterator_entry(i);
-			a[index++] = s;
-		}
-		qsort(a, count, sizeof(a[0]), _compar);
+	index = 0;
+	snd_config_for_each(i, next, src) {
+		snd_config_t *s = snd_config_iterator_entry(i);
+		a[index++] = s;
 	}
+	if (array <= 0)
+		qsort(a, count, sizeof(a[0]), _compar);
 	if (snd_config_make_compound(&dst, id, count == 1)) {
 		free(a);
 		return NULL;
-- 
2.16.4