<html><head></head><body><div class="gmail_quote">Le 13 juillet 2017 14:22:13 GMT+08:00, Steve Lhomme <robux4@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;">
<pre class="k9mail">On Wed, Jul 12, 2017 at 5:24 PM, Rémi Denis-Courmont <remi@remlab.net> wrote:<br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> On mercredi 12 juillet 2017 16:51:19 EEST Steve Lhomme wrote:<br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> It must copy to an unitialized structure or one that was cleaned before.<br /><br /> The result should always be checked as there are allocations that can fail<br /> but it's not safe for now given the state of the rest of the code.<br /> ---<br /> include/vlc_es.h | 3 +++<br /> 1 file changed, 3 insertions(+)<br /><br /> diff --git a/include/vlc_es.h b/include/vlc_es.h<br /> index e9d11d85a8..a428b561c2 100644<br /> --- a/include/vlc_es.h<br /> +++ b/include/vlc_es.h<br /> @@ -627,7 +627,10 @@ VLC_API void es_format_InitFromVideo( es_format_t *,<br /> const video_format_t * );<br /><br /> /**<br /> * This functions will copy a es_format_t.<br /> + *<br /> + * The destination pointer must be uninitialized or not old any allocated<br /></blockquote></blockquote><br />Typo "hold"<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> buffer. */<br /> +/* VLC_USED for now we're okay with losing strings and extradata */<br /> VLC_API int es_format_Copy( es_format_t *p_dst, const es_format_t *p_src );<br /><br /> /**<br /></blockquote><br /> No. The error is impossible in some code paths (e.g. audio filters), and<br /> totally harmless in others. Littering the code base with untested, buggy and<br /> sometimes dead, error code does not make sense.<br /><br /> You can't add VLC_USED then, since ignoring the result is not always a bug.<br /></blockquote><br />OK<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> And video.p_palette should die. And language should be a small fixed size<br /></blockquote><br />I think the reason to use a union was to save space. If we force<br />psz_language and psz_description to fixed size buffers we lose that<br />advantage and we gain strings that may not always fit the strings we<br />want to store.<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> character array. That leaves only p_extra IIRC.<br /></blockquote><br />There's also p_extra_languages, subs.psz_encoding and subs.p_style.<br /><br />So dynamically allocated memory in es_format_t is not going away<br />anytime soon (if ever). We should make sure it's handled properly and<br />make it harder to have leaks.<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> --<br /> Rémi Denis-Courmont<br /><hr /><br /> vlc-devel mailing list<br /> To unsubscribe or modify your subscription options:<br /> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br /></blockquote><hr /><br />vlc-devel mailing list<br />To unsubscribe or modify your subscription options:<br /><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br clear="all">A language code is at most 8 bytes including nul. It is no more space than the pointer.<br>
-- <br>
Rémi Denis-Courmont<br>
Typed on an inconvenient virtual keyboard</body></html>