Hello,

Hello Coverity detected that dvb_guess_user_country introduces a
resource leak (CID 1250445).

On 31/10/14 14:13, tsk...@gmail.com wrote:
> +enum dvb_country_t dvb_guess_user_country(void)
> +{
> +     char * buf, * pch, * pbuf;
> +     unsigned cat;
> +     enum dvb_country_t id = COUNTRY_UNKNOWN;
> +
> +     for (cat = 0; cat < sizeof(cats)/sizeof(cats[0]); cat++) {
> +
> +             // the returned char * should be "C", "POSIX" or something 
> valid.
> +             // If valid, we can only *guess* which format is returned.
> +             // Assume here something like "de_DE.iso8859-1@euro" or 
> "de_DE.utf-8"
> +             buf = secure_getenv(cats[cat]);
> +             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;
> +
> +             // assuming 'language_country.encoding@variant'
> +
> +             // country after '_', if given
> +             if ((pch = strchr(buf, '_')))
> +                     pbuf = pch + 1;
> +
> +             // remove all after '@', including '@'
> +             if ((pch = strchr(pbuf, '@')))
> +                     *pch = 0;
> +
> +             // remove all after '.', including '.'
> +             if ((pch = strchr(pbuf, '.')))
> +                     *pch = 0;
> +
> +             if (strlen(pbuf) == 2)
> +                     id = dvb_country_a2_to_id(pbuf);
> +             free(buf);
> +             if (id != COUNTRY_UNKNOWN)
> +                     return id;
> +     }
> +
> +     return COUNTRY_UNKNOWN;
> +}

pbuf / buf may get leaked due to the continue statement.

Could you please post a patch?

Thanks,
Gregor
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to