The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other

just makes it possible to compile if USE_ICONV is undefined.

Patch by Bjorn Sandell (biorn _At_ chalmers _Dot_ se).


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17932 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
albeu 2006-03-24 02:31:29 +00:00
parent b7e160dbe9
commit 35e90f1556
2 changed files with 13 additions and 1 deletions

View File

@ -18,7 +18,9 @@
#include <math.h>
#include <string.h>
#ifdef USE_ICONV
#include <iconv.h>
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
@ -731,7 +733,7 @@ int generate_tables(font_desc_t *desc, double thickness, double radius)
return 0;
}
#ifdef USE_ICONV
/* decode from 'encoding' to unicode */
static FT_ULong decode_char(iconv_t *cd, char c) {
FT_ULong o;
@ -830,6 +832,7 @@ static int prepare_charset_unicode(FT_Face face, FT_ULong *charset, FT_ULong *ch
return i;
}
#endif
static font_desc_t* init_font_desc(void)
{
@ -1015,6 +1018,7 @@ font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height)
}
desc->face_cnt++;
#ifdef USE_ICONV
if (unicode) {
charset_size = prepare_charset_unicode(face, my_charset, my_charcodes);
} else {
@ -1030,6 +1034,9 @@ font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height)
free_font_desc(desc);
return NULL;
}
#else
return NULL;
#endif
// fprintf(stderr, "fg: prepare t = %lf\n", GetTimer()-t);

View File

@ -102,6 +102,10 @@ void mp_msg(int mod, int lev, const char *format, ... ){
msgiconv = iconv_open(mp_msg_charset, MSG_CHARSET);
old_charset = strdup(mp_msg_charset);
}
if (msgiconv == (iconv_t)(-1)) {
fprintf(stderr,"iconv: conversion from %s to %s unsupported\n"
,mp_msg_charset,MSG_CHARSET);
}else{
memset(tmp2, 0, MSGSIZE_MAX);
while (iconv(msgiconv, &in, &inlen, &out, &outlen) == -1) {
if (!inlen || !outlen)
@ -113,6 +117,7 @@ void mp_msg(int mod, int lev, const char *format, ... ){
tmp[MSGSIZE_MAX-1] = 0;
tmp[MSGSIZE_MAX-2] = '\n';
}
}
#endif
#ifdef MSG_USE_COLORS