File 0008-alsaucm-Don-t-double-free-empty-lists.patch of Package alsa-utils

From f30fbe3901da0f57a6b40102ae1c3ab3a9ff6744 Mon Sep 17 00:00:00 2001
From: Stephen Warren <swarren@nvidia.com>
Date: Thu, 2 Jun 2011 16:45:13 -0600
Subject: [PATCH 08/16] alsaucm: Don't double-free empty lists

When snd_use_case_get_list (and hence also snd_use_case_card_list) returns
an empty list, alsaucm still attempts to free it. This ends up double-
freeing the returned list, or worse, freeing an invalid pointer, depending
on how snd_use_case_get_list gets implemented. Fix alsaucm to return early
on empty lists to avoid this.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
 alsaucm/usecase.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/alsaucm/usecase.c b/alsaucm/usecase.c
index f24e63e..1c94680 100644
--- a/alsaucm/usecase.c
+++ b/alsaucm/usecase.c
@@ -226,8 +226,10 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
 				snd_strerror(err));
 			return err;
 		}
-		if (err == 0)
+		if (err == 0) {
 			printf("  list is empty\n");
+			return 0;
+		}
 		for (i = 0; i < err / 2; i++) {
 			printf("  %i: %s\n", i, list[i*2]);
 			if (list[i*2+1])
@@ -256,8 +258,10 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
 				snd_strerror(err));
 			return err;
 		}
-		if (err == 0)
+		if (err == 0) {
 			printf("  list is empty\n");
+			return 0;
+		}
 		for (i = 0; i < err / entries; i++) {
 			printf("  %i: %s\n", i, list[i*entries]);
 			for (j = 0; j < entries - 1; j++)
-- 
1.7.5.3
openSUSE Build Service is sponsored by