Sophie

Sophie

distrib > Fedora > 16 > x86_64 > by-pkgid > b10490245063b25104ad1d93e768d6a1 > files > 11

v4l-utils-0.8.8-2.fc16.src.rpm

From 1539b9211634f3546d08fa36593b02bf2fa3903a Mon Sep 17 00:00:00 2001
From: Gregor Jasny <gjasny@googlemail.com>
Date: Thu, 2 Feb 2012 20:25:07 +0100
Subject: [PATCH 11/12] libv4lconvert: replace strndupa with more portable
 strndup

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
---
 lib/libv4lconvert/control/libv4lcontrol.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/libv4lconvert/control/libv4lcontrol.c b/lib/libv4lconvert/control/libv4lcontrol.c
index 8795e2f..f312354 100644
--- a/lib/libv4lconvert/control/libv4lcontrol.c
+++ b/lib/libv4lconvert/control/libv4lcontrol.c
@@ -452,6 +452,7 @@ static int find_dmi_string(const char **table_entries, const char *dmi_value)
 	const char **entry_ptr;
 	char *trimmed_dmi;
 	size_t n;
+	int found = 0;
 
 	if (!start) return 0;
 
@@ -459,16 +460,19 @@ static int find_dmi_string(const char **table_entries, const char *dmi_value)
 	while (isspace(*start)) start++;
 	n = strlen(start);
 	while (n > 0 && isspace(start[n-1])) --n;
-	trimmed_dmi = strndupa(start, n);
+	trimmed_dmi = strndup(start, n);
 
 	/* find trimmed value */
 	for (entry_ptr = table_entries; *entry_ptr;  entry_ptr++) {
-		const int found = fnmatch(*entry_ptr, trimmed_dmi, 0) == 0;
+		found = fnmatch(*entry_ptr, trimmed_dmi, 0) == 0;
 		/* fprintf(stderr, "find_dmi_string('%s', '%s'->'%s')=%i\n", *entry_ptr, dmi_value, trimmed_dmi, found); */
 		if (found)
-			return 1;
+			break;
 	}
-	return 0;
+
+	free(trimmed_dmi);
+
+	return found;
 }
 
 /*
-- 
1.7.10