Browse Source

Fix null pointer dereference

When looking up translated font names within font files, it was not
checking for null on the 'charset' variable (the translation character
set wasn't added/availble).
jp9000 11 years ago
parent
commit
cf1b106a26
1 changed files with 10 additions and 0 deletions
  1. 10 0
      plugins/text-freetype2/find-font-iconv.c

+ 10 - 0
plugins/text-freetype2/find-font-iconv.c

@@ -127,6 +127,16 @@ char *sfnt_name_to_utf8(FT_SfntName *sfnt_name)
 	char *conv_in, *conv_out;
 	char *conv_in, *conv_out;
 	size_t in_len, out_len;
 	size_t in_len, out_len;
 
 
+	if (!charset) {
+		blog(LOG_DEBUG, "invalid character set found, "
+		                "platform_id: %d, encoding_id: %d, "
+		                "language_id: %d",
+		                sfnt_name->platform_id,
+		                sfnt_name->encoding_id,
+		                sfnt_name->language_id);
+		return NULL;
+	}
+
 	iconv_t ic = iconv_open("UTF-8", charset);
 	iconv_t ic = iconv_open("UTF-8", charset);
 	if (ic == (iconv_t)-1) {
 	if (ic == (iconv_t)-1) {
 		blog(LOG_WARNING, "couldn't intialize font code page "
 		blog(LOG_WARNING, "couldn't intialize font code page "