mirror of
https://github.com/mpv-player/mpv
synced 2024-12-17 04:15:13 +00:00
strdup() of a NULL pointer, truckload of cola for me
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15383 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
6f68b43715
commit
ce70204266
14
subreader.c
14
subreader.c
@ -1323,11 +1323,16 @@ void* guess_cp(FILE *fd, char *preferred_language, char *fallback)
|
|||||||
mp_msg(MSGT_SUBREADER, MSGL_V, "\n");
|
mp_msg(MSGT_SUBREADER, MSGL_V, "\n");
|
||||||
|
|
||||||
for (i = 0; i < langcnt; i++) {
|
for (i = 0; i < langcnt; i++) {
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
if (strcasecmp(languages[i], preferred_language) != 0) continue;
|
if (strcasecmp(languages[i], preferred_language) != 0) continue;
|
||||||
analyser = enca_analyser_alloc(languages[i]);
|
analyser = enca_analyser_alloc(languages[i]);
|
||||||
encoding = enca_analyse_const(analyser, buffer, buflen);
|
encoding = enca_analyse_const(analyser, buffer, buflen);
|
||||||
mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detected charset: %s\n", enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV));
|
tmp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
|
||||||
detected_sub_cp = strdup(enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV));
|
if (tmp) {
|
||||||
|
detected_sub_cp = strdup(tmp);
|
||||||
|
mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detected charset: %s\n", tmp);
|
||||||
|
}
|
||||||
enca_analyser_free(analyser);
|
enca_analyser_free(analyser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1335,7 +1340,10 @@ void* guess_cp(FILE *fd, char *preferred_language, char *fallback)
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
rewind(fd);
|
rewind(fd);
|
||||||
|
|
||||||
if (!detected_sub_cp) detected_sub_cp = strdup(fallback);
|
if (!detected_sub_cp) {
|
||||||
|
detected_sub_cp = strdup(fallback);
|
||||||
|
mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detection failed: fallback to %s\n", fallback);
|
||||||
|
}
|
||||||
|
|
||||||
return detected_sub_cp;
|
return detected_sub_cp;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user