Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
ce3bebae by Steve Lhomme at 2025-08-01T06:17:41+00:00
modules: fix vlc_memstream_close success checks

It doesn't return VLC_SUCCESS but 0 (even though it's the same thing).

(cherry picked from commit 05761dd35816a6f4086b8f3da9b9ba6684e736ea)

- - - - -
7e15be40 by Steve Lhomme at 2025-08-01T06:17:41+00:00
webvtt: don't reset empty memstream pointer

The content is later used with vlc_memstream_write. Passing NULL is undefined.
On Windows it uses fwrite which doesn't allow passing NULL [1].

[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fwrite

(cherry picked from commit 932a1c3e9cd476ff650d5a6a497a9aad351e8227)

- - - - -
b2e8eaaf by Steve Lhomme at 2025-08-01T06:17:41+00:00
core: set VLC_MALLOC on strings allocated by a memstream

After vlc_memstream_close() the memstream cannot be used anymore.

(cherry picked from commit 02b47bc2e4c5e612bc7f38412ade12c0f676f3d9) (edited)
- vlc_strfplayer is vlc_strfinput in 3.0
- es_out and vlc_player don't have the related API's in 3.0

- - - - -
1e71d438 by Steve Lhomme at 2025-08-01T06:17:41+00:00
modules: set VLC_MALLOC on strings allocated by a memstream

After vlc_memstream_close() the memstream cannot be used anymore.

(cherry picked from commit e52cc89f8077c4cf264faabec470b09cd70d8d9a) (edited)
edited:
- the smb2 code doesn't have the extra line ending
- 3.0 doesn't have the HLS stream output.

- - - - -
1fd71e04 by Steve Lhomme at 2025-08-01T06:17:41+00:00
mrl_helpers: return the escaped string in mrl_EscapeFragmentIdentifier

We don't need an error code.

(cherry picked from commit 6c9543c4d435d23d16c496589ea2201d9c2d420a)

- - - - -


14 changed files:

- include/vlc_strings.h
- modules/access/http/message.h
- modules/access/smb2.c
- modules/codec/webvtt/subsvtt.c
- modules/demux/playlist/asx.c
- modules/demux/ttml.c
- modules/demux/webvtt.c
- modules/keystore/kwallet.c
- modules/stream_out/es.c
- src/input/mrl_helpers.h
- src/input/stream_extractor.c
- src/input/vlmshell.c
- src/test/mrl_helpers.c
- src/text/url.c


Changes:

=====================================
include/vlc_strings.h
=====================================
@@ -138,7 +138,7 @@ VLC_API char *vlc_strftime( const char * );
  *
  * Formats input and input item meta-informations into a heap-allocated string.
  */
-VLC_API char *vlc_strfinput( input_thread_t *, const char * );
+VLC_API char *vlc_strfinput( input_thread_t *, const char * ) VLC_MALLOC;
 
 static inline char *str_format( input_thread_t *input, const char *fmt )
 {


=====================================
modules/access/http/message.h
=====================================
@@ -401,7 +401,7 @@ static inline void vlc_http_stream_close(struct 
vlc_http_stream *s, bool abort)
  *         or NULL on error
  */
 char *vlc_http_msg_format(const struct vlc_http_msg *m, size_t *restrict lenp,
-                          bool proxied) VLC_USED;
+                          bool proxied) VLC_USED VLC_MALLOC;
 
 /**
  * Parses an HTTP 1.1 message header.


=====================================
modules/access/smb2.c
=====================================
@@ -407,7 +407,7 @@ FileControl(stream_t *access, int i_query, va_list args)
     return VLC_SUCCESS;
 }
 
-static char *
+VLC_MALLOC static char *
 vlc_smb2_get_url(vlc_url_t *url, const char *file)
 {
     /* smb2://<psz_host><i_port><psz_path><file>?<psz_option> */


=====================================
modules/codec/webvtt/subsvtt.c
=====================================
@@ -1968,7 +1968,7 @@ static void ParserHeaderHandler( void *priv, enum 
webvtt_header_line_e s,
 #ifdef HAVE_CSS
         else if( ctx->b_css_memstream_opened )
         {
-            if( vlc_memstream_close( &ctx->css ) == VLC_SUCCESS )
+            if( vlc_memstream_close( &ctx->css ) == 0 )
             {
                 vlc_css_parser_t p;
                 vlc_css_parser_Init(&p);


=====================================
modules/demux/playlist/asx.c
=====================================
@@ -439,7 +439,7 @@ static void memstream_puts_xmlencoded(struct vlc_memstream* 
p_stream, const char
  *  - make tags and attributes upercase
  *  - escape strings when required
  */
-static char* ASXToXML( char* psz_source )
+VLC_MALLOC static char* ASXToXML( char* psz_source )
 {
     bool b_in_string= false;
     char *psz_source_cur = psz_source;


=====================================
modules/demux/ttml.c
=====================================
@@ -377,7 +377,7 @@ static int Demux( demux_t* p_demux )
         tt_node_ToText( &stream, (tt_basenode_t *) p_sys->p_rootnode,
                         &p_sys->times.p_array[p_sys->times.i_current] );
 
-        if( vlc_memstream_close( &stream ) == VLC_SUCCESS )
+        if( vlc_memstream_close( &stream ) == 0 )
         {
             block_t* p_block = block_heap_Alloc( stream.ptr, stream.length );
             if( p_block )
@@ -523,7 +523,7 @@ int tt_OpenDemux( vlc_object_t* p_this )
 
         vlc_memstream_putc( &stream, '\0' );
 
-        if( vlc_memstream_close( &stream ) == VLC_SUCCESS )
+        if( vlc_memstream_close( &stream ) == 0 )
         {
             msg_Dbg( p_demux, "%s", stream.ptr );
             free( stream.ptr );


=====================================
modules/demux/webvtt.c
=====================================
@@ -133,10 +133,9 @@ static block_t *ConvertWEBVTT( const webvtt_cue_t *p_cue, 
bool b_continued )
     vlc_memstream_write( &stream, paylbox, 8 );
     vlc_memstream_write( &stream, p_cue->psz_text, paylsize - 8 );
 
-    if( vlc_memstream_close( &stream ) == VLC_SUCCESS )
+    if( vlc_memstream_close( &stream ) == 0 )
         return block_heap_Alloc( stream.ptr, stream.length );
-    else
-        return NULL;
+    return NULL;
 }
 
 struct memstream_wrap
@@ -156,13 +155,8 @@ static void memstream_Append( struct memstream_wrap *mw, 
const char *psz )
 
 static void memstream_Grab( struct memstream_wrap *mw, void **pp, size_t *pi )
 {
-    if( mw->b_opened && vlc_memstream_close( &mw->memstream ) == VLC_SUCCESS )
+    if( mw->b_opened && vlc_memstream_close( &mw->memstream ) == 0 )
     {
-        if( mw->memstream.length == 0 )
-        {
-            free( mw->memstream.ptr );
-            mw->memstream.ptr = NULL;
-        }
         *pp = mw->memstream.ptr;
         *pi = mw->memstream.length;
     }
@@ -423,7 +417,7 @@ static void MakeExtradata( demux_sys_t *p_sys, void 
**p_extra, size_t *pi_extra
                                      p_sys->regions_headers.i_data );
     vlc_memstream_write( &extradata, p_sys->styles_headers.p_data,
                                      p_sys->styles_headers.i_data );
-    if( vlc_memstream_close( &extradata ) == VLC_SUCCESS )
+    if( vlc_memstream_close( &extradata ) == 0 )
     {
         if( extradata.length )
         {


=====================================
modules/keystore/kwallet.c
=====================================
@@ -109,7 +109,7 @@ typedef struct vlc_keystore_sys
 
 /* takes all values in the values of vlc_keystore_entry *
  * and formats them in a url key */
-static char*
+VLC_MALLOC static char*
 values2key( const char* const* ppsz_values, bool b_search )
 {
     char* psz_b64_realm = NULL;


=====================================
modules/stream_out/es.c
=====================================
@@ -209,8 +209,8 @@ struct sout_stream_id_sys_t
     sout_mux_t   *p_mux;
 };
 
-static char * es_print_url( const char *psz_fmt, vlc_fourcc_t i_fourcc, int 
i_count,
-                            const char *psz_access, const char *psz_mux )
+VLC_MALLOC static char * es_print_url( const char *psz_fmt, vlc_fourcc_t 
i_fourcc, int i_count,
+                                       const char *psz_access, const char 
*psz_mux )
 {
     struct vlc_memstream stream;
     unsigned char c;


=====================================
src/input/mrl_helpers.h
=====================================
@@ -49,13 +49,11 @@
  * See the \link mrl MRL-specification\endlink for a detailed
  * explanation of how `payload` will be escaped.
  *
- * \param[out] out `*out` will refer to the created string on success,
- *                  and an unspecified value on error.
  * \param[in] payload the data to escape.
- * \return VLC_SUCCESS on success, an error-code on failure.
+ * \return he created string on success, and NULL on error.
  **/
-static inline int
-mrl_EscapeFragmentIdentifier( char** out, char const* payload )
+VLC_MALLOC static inline char *
+mrl_EscapeFragmentIdentifier( char const* payload )
 {
     struct vlc_memstream mstream;
 
@@ -69,7 +67,7 @@ mrl_EscapeFragmentIdentifier( char** out, char const* payload 
)
 #define RFC3986_FRAGMENT   RFC3986_PCHAR "/" "?"
 
     if( vlc_memstream_open( &mstream ) )
-        return VLC_EGENERIC;
+        return NULL;
 
     for( char const* p = payload; *p; ++p )
     {
@@ -86,10 +84,9 @@ mrl_EscapeFragmentIdentifier( char** out, char const* 
payload )
 #undef RFC3986_SUBDELIMS
 
     if( vlc_memstream_close( &mstream ) )
-        return VLC_EGENERIC;
+        return NULL;
 
-    *out = mstream.ptr;
-    return VLC_SUCCESS;
+    return mstream.ptr;
 }
 
 /**


=====================================
src/input/stream_extractor.c
=====================================
@@ -85,13 +85,14 @@ struct stream_extractor_private {
  * within \ref base, see \ref mrl_helpers for further information.
  **/
 
-static char*
+VLC_MALLOC static char*
 StreamExtractorCreateMRL( char const* base, char const* subentry )
 {
     struct vlc_memstream buffer;
     char* escaped;
 
-    if( mrl_EscapeFragmentIdentifier( &escaped, subentry ) )
+    escaped = mrl_EscapeFragmentIdentifier( subentry );
+    if ( escaped == NULL )
         return NULL;
 
     if( vlc_memstream_open( &buffer ) )


=====================================
src/input/vlmshell.c
=====================================
@@ -65,7 +65,7 @@ static vlm_message_t *vlm_Show( vlm_t *, vlm_media_sys_t *, 
vlm_schedule_sys_t *
 
 static vlm_schedule_sys_t *vlm_ScheduleSearch( vlm_t *, const char * );
 
-static char *Save( vlm_t * );
+VLC_MALLOC static char *Save( vlm_t * );
 static int Load( vlm_t *, char * );
 
 static vlm_schedule_sys_t *vlm_ScheduleNew( vlm_t *vlm, const char *psz_name );
@@ -1593,7 +1593,7 @@ static int Load( vlm_t *vlm, char *file )
     return 0;
 }
 
-static char *Save( vlm_t *vlm )
+VLC_MALLOC static char *Save( vlm_t *vlm )
 {
     const char *psz_header = "\n"
                              "# VLC media player VLM command batch\n"


=====================================
src/test/mrl_helpers.c
=====================================
@@ -89,9 +89,8 @@ int main (void)
 
                 assert(strcmp(testcase[i].results[j], res) == 0);
 
-                char *res_escaped = NULL;
-                ret = mrl_EscapeFragmentIdentifier(&res_escaped, res);
-                assert(ret == VLC_SUCCESS && res_escaped != NULL);
+                char *res_escaped = mrl_EscapeFragmentIdentifier(res);
+                assert(res_escaped != NULL);
                 assert(strncmp(p, res_escaped, strlen(res_escaped)) == 0);
                 p += strlen(res_escaped) + 2;
 


=====================================
src/text/url.c
=====================================
@@ -829,7 +829,7 @@ error:
     return ret;
 }
 
-static char *vlc_uri_fixup_inner(const char *str, const char *extras)
+VLC_MALLOC static char *vlc_uri_fixup_inner(const char *str, const char 
*extras)
 {
     assert(str && extras);
 



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/eaa8a3c3a0a58bb9ec8caeaf3c1372be3da1b93a...1fd71e04f1140d3b42555d9a3c101c7e436460c7

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/eaa8a3c3a0a58bb9ec8caeaf3c1372be3da1b93a...1fd71e04f1140d3b42555d9a3c101c7e436460c7
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to