diff mbox

v4l-utils/libdvbv5: fix memory leak in dvb_guess_user_country()

Message ID 1414929817-11834-1-git-send-email-tskd08@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Akihiro TSUKADA Nov. 2, 2014, 12:03 p.m. UTC
From: Akihiro Tsukada <tskd08@gmail.com>

Signed-off-by: Akihiro Tsukada <tskd08@gmail.com>
---
 lib/libdvbv5/countries.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/lib/libdvbv5/countries.c b/lib/libdvbv5/countries.c
index 7acdcc7..9e68ea6 100644
--- a/lib/libdvbv5/countries.c
+++ b/lib/libdvbv5/countries.c
@@ -395,13 +395,13 @@  enum dvb_country_t dvb_guess_user_country(void)
 		if (! buf || strlen(buf) < 2)
 			continue;
 
-		buf = strdup(buf);
-		pbuf= buf;
-
 		if (! strncmp(buf, "POSIX", MIN(strlen(buf), 5)) ||
 		    ! (strncmp(buf, "en", MIN(strlen(buf), 2)) && !isalpha(buf[2])) )
 			continue;
 
+		buf = strdup(buf);
+		pbuf= buf;
+
 		// assuming 'language_country.encoding@variant'
 
 		// country after '_', if given