changeset 17931:ed9950b8200d

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).
author albeu
date Fri, 24 Mar 2006 02:31:29 +0000
parents 81cbc8debd3c
children 3fe3b2b3a6ce
files libvo/font_load_ft.c mp_msg.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/font_load_ft.c	Fri Mar 24 01:32:04 2006 +0000
+++ b/libvo/font_load_ft.c	Fri Mar 24 02:31:29 2006 +0000
@@ -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 @@
     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 @@
 
     return i;
 }
+#endif
 
 static font_desc_t* init_font_desc(void)
 {
@@ -1015,6 +1018,7 @@
     }
     desc->face_cnt++;
 
+#ifdef USE_ICONV
     if (unicode) {
 	charset_size = prepare_charset_unicode(face, my_charset, my_charcodes);
     } else {
@@ -1030,6 +1034,9 @@
 	free_font_desc(desc);
 	return NULL;
     }
+#else
+    return NULL;
+#endif
 
 //    fprintf(stderr, "fg: prepare t = %lf\n", GetTimer()-t);
 
--- a/mp_msg.c	Fri Mar 24 01:32:04 2006 +0000
+++ b/mp_msg.c	Fri Mar 24 02:31:29 2006 +0000
@@ -102,6 +102,10 @@
         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)
@@ -112,6 +116,7 @@
       strncpy(tmp, tmp2, MSGSIZE_MAX);
       tmp[MSGSIZE_MAX-1] = 0;
       tmp[MSGSIZE_MAX-2] = '\n';
+      }
     }
 #endif