[vlc-devel] [PATCH 2/8] stream_ReadLine: reset iconv state on conversion error

Pierre Ynard linkfanel at yahoo.fr
Wed Oct 21 05:23:01 CEST 2020


Tested against UTF-16 lone surrogates, for which it seems to make no
difference


diff --git a/src/input/stream.c b/src/input/stream.c
index 90651de..376cbc9 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -350,6 +350,9 @@ char *vlc_stream_ReadLine( stream_t *s )
             {
                 msg_Err( s, "conversion error: %s", vlc_strerror_c( errno ) );
                 msg_Dbg( s, "original: %d, in %zu, out %zu", i_line, i_in, i_out );
+                /* Reset state */
+                size_t r = vlc_iconv( priv->text.conv, NULL, NULL, NULL, NULL );
+                VLC_UNUSED( r );
             }
             free( p_line );
             p_line = psz_new_line;
-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."


More information about the vlc-devel mailing list