Index: libsub/ass.c
===================================================================
--- libsub/ass.c	(revision 338)
+++ libsub/ass.c	(revision 340)
@@ -608,13 +608,20 @@
 }
 #endif // HAVE_ENCA
 
+/** \brief recode buffer to utf-8
+ * constraint: sub_cp != 0
+ * \param data pointer to text buffer
+ * \param size buffer size
+ * \return a pointer to recoded buffer, caller is responsible for freeing it
+**/
 static char* sub_recode(char* data, int size)
 {
 	static iconv_t icdsc = (iconv_t)(-1);
 	char* tocp = "UTF-8";
 	char* outbuf;
+	assert(sub_cp);
 
-	if (sub_cp){
+	{
 		char* cp_tmp = sub_cp;
 #ifdef HAVE_ENCA
 		char enca_lang[3], enca_fallback[100];
@@ -662,7 +669,7 @@
 		outbuf[osize - oleft - 1] = 0;
 	}
 
-	if (icdsc != (iconv_t)(-1)){
+	if (icdsc != (iconv_t)(-1)) {
 		(void) iconv_close (icdsc);
 		icdsc = (iconv_t)(-1);
 		mp_msg(MSGT_SUBREADER,MSGL_V,"LIBSUB: closed iconv descriptor.\n");
@@ -727,7 +734,7 @@
 	fclose(fp);
 	
 #ifdef USE_ICONV
-	{
+	if (sub_cp) {
 		char* tmpbuf = sub_recode(buf, sz);
 		free(buf);
 		if (!tmpbuf)
