<div>From d274065aeb20b6538a108bb310e7c8ab2445e5fd Mon Sep 17 00:00:00 2001</div><div>From: Shaleen Jain <shaleen.jain95@gmail.com></div><div>Date: Fri, 23 Jun 2017 15:26:40 +0530</div><div>Subject: [PATCH] stream: iconv: convert only if we have a conversion descriptor</div><div><br></div><div>---</div><div> src/input/stream.c | 6 ++++--</div><div> 1 file changed, 4 insertions(+), 2 deletions(-)</div><div><br></div><div>diff --git a/src/input/stream.c b/src/input/stream.c</div><div>index affc7b2c0d..ecdaa2f997 100644</div><div>--- a/src/input/stream.c</div><div>+++ b/src/input/stream.c</div><div>@@ -195,6 +195,7 @@ char *vlc_stream_ReadLine( stream_t *s )</div><div>         if( i_pos == 0 && i_data >= 2 )</div><div>         {</div><div>             const char *psz_encoding = NULL;</div><div>+          priv->text.conv = (vlc_iconv_t)-1;</div><div> </div><div>             if( unlikely(priv->text.conv != (vlc_iconv_t)-1) )</div><div>             {   /* seek back to beginning? reset */</div><div>@@ -220,7 +221,7 @@ char *vlc_stream_ReadLine( stream_t *s )</div><div>                 if( unlikely(priv->text.conv == (vlc_iconv_t)-1) )</div><div>                 {</div><div>                     msg_Err( s, "iconv_open failed" );</div><div>-                    goto error;</div><div>+            <span style="white-space: pre-wrap;">      </span>return NULL;</div><div>                 }</div><div>                 priv->text.char_width = 2;</div><div>             }</div><div>@@ -327,7 +328,8 @@ char *vlc_stream_ReadLine( stream_t *s )</div><div>             p_in = p_line;</div><div>             p_out = psz_new_line;</div><div> </div><div>-            if( vlc_iconv( priv->text.conv, &p_in, &i_in, &p_out, &i_out ) == (size_t)-1 )</div><div>+          if( priv->text.conv != (vlc_iconv_t)-1 &&</div><div>+            <span class="Apple-tab-span" style="white-space:pre">      </span>        vlc_iconv( priv->text.conv, &p_in, &i_in, &p_out, &i_out ) == (size_t)-1 )</div><div>             {</div><div>                 msg_Err( s, "conversion error: %s", vlc_strerror_c( errno ) );</div><div>                 msg_Dbg( s, "original: %d, in %zu, out %zu", i_line, i_in, i_out );</div><div>-- </div><div>2.13.1</div><div><br></div>

On Thu, Jun 22, 2017 at 5:45 PM, Rémi Denis-Courmont <remi@remlab.net> wrote:<br>
<blockquote type="cite"><div class="gmail_quote">Le 22 juin 2017 14:44:49 GMT+03:00, Shaleen Jain <shaleen.jain95@gmail.com> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>

On Wed, Jun 21, 2017 at 11:38 PM, Rémi Denis-Courmont <remi@remlab.net> wrote:<br>
<blockquote type="cite"><div class="plaintext" style="white-space: pre-wrap;">Le keskiviikkona 21. kesäkuuta 2017, 22.55.37 EEST Shaleen Jain a écrit :
<blockquote> How so?
</blockquote>
It´s still not resulting in anything sane.</div></blockquote>I'm sorry I don't see how the logic is incorrect, <div>if priv->text.conv is -1 (which will happen if vlc_iconv_open() fails)</div><div>priv->text.conv != (vlc_iconv_t)(-1) would be false and vlc_iconv() would not run, otherwise it would proceed to do the conversion.<br><blockquote type="cite"><div class="plaintext" style="white-space: pre-wrap;">

<div>-- 
</div>雷米‧德尼-库尔蒙
<a href="https://www.remlab.net/">https://www.remlab.net/</a>
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
<a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></div></blockquote><br><br>
</div></blockquote></div><br clear="all">Skipping the conversion is not going to result in sane behaviour.</blockquote>It isn't suppose to do anything sane by itself, it's a sanity check for when psz_encoding is null and the program doesn't need to do a conversion.<div><br></div><div>Also "goto error" when iconv_open fails is going to result in a invalid free of p_line.</div><div><br></div><div>Besides if you are not going to provide any constructive review and take someone else's patches and try to implement it yourself, without posting on the mailing list and be counter-productive then you might just as well do a fork.<br><blockquote type="cite"><br>
-- <br>
Rémi Denis-Courmont<br>
Typed on an inconvenient virtual keyboard</blockquote><br><br>
</div>