]> granicus.if.org Git - handbrake/commitdiff
libhb: fix use of uninitialized variable in lang.c
authorJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 29 Jan 2016 16:05:44 +0000 (09:05 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 29 Jan 2016 16:05:44 +0000 (09:05 -0700)
It caused crashes in some builds

libhb/lang.c
libhb/lang.h

index a8ed2e8c8eef59f26c9bd60d0a19512732952642..c51c80ad51ec0c99ced50fe85c85d2f903d11fb6 100644 (file)
@@ -205,7 +205,7 @@ static const int lang_count = sizeof(languages) / sizeof(languages[0]);
 const int lang_lookup_index( const char * str )
 {
     int             ii = 0;
-    iso639_lang_t * lang;
+    const iso639_lang_t * lang;
 
     // We use "Any" as a synonym for undefined
     if (!strcasecmp("any", str))
@@ -213,7 +213,7 @@ const int lang_lookup_index( const char * str )
         return 0;
     }
 
-    for (ii = 0; lang->eng_name; ii++)
+    for (ii = 0; languages[ii].eng_name; ii++)
     {
         lang = &languages[ii];
         if ((lang->iso639_1    != NULL && !strcasecmp(lang->iso639_1,  str)) ||
@@ -234,7 +234,7 @@ const iso639_lang_t * lang_lookup( const char * str )
     return lang_for_index(lang_lookup_index(str));
 }
 
-iso639_lang_t * lang_for_index( int index )
+const iso639_lang_t * lang_for_index( int index )
 {
     if (index < 0 || index >= lang_count)
         return NULL;
index 7d794910c8eb6a244aa809faac4819897fd3c6ca..a0db17162c8e6dd45d9014fe6a83ac20e871dcd6 100644 (file)
@@ -30,7 +30,7 @@ const iso639_lang_t * lang_lookup( const char * str );
 const int lang_lookup_index( const char * str );
 
 /* return language for an index into the language table */
-iso639_lang_t * lang_for_index( int index );
+const iso639_lang_t * lang_for_index( int index );
 
 /* find language associated with ISO-639-1 language code */
 iso639_lang_t * lang_for_code( int code );