[vlc-devel] commit: Services discoveries: check memory allocation ( Rafaël Carré )

git version control git at videolan.org
Thu Mar 27 00:45:53 CET 2008


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Thu Mar 27 00:44:50 2008 +0100| [d51dba48f9065eba4c167d21fe5258807e0da43f]

Services discoveries: check memory allocation

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d51dba48f9065eba4c167d21fe5258807e0da43f
---

 modules/services_discovery/bonjour.c |    8 +++-----
 modules/services_discovery/podcast.c |    2 ++
 modules/services_discovery/sap.c     |    2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/modules/services_discovery/bonjour.c b/modules/services_discovery/bonjour.c
index be56e32..482809a 100644
--- a/modules/services_discovery/bonjour.c
+++ b/modules/services_discovery/bonjour.c
@@ -270,11 +270,9 @@ static int Open( vlc_object_t *p_this )
 
     p_sd->p_sys = p_sys = (services_discovery_sys_t *)malloc(
         sizeof( services_discovery_sys_t ) );
-    if( p_sd->p_sys == NULL )
-    {
-        msg_Err( p_sd, "out of memory" );
-        return VLC_EGENERIC;
-    }
+
+    if( !p_sys )
+        return VLC_ENOMEM;
 
     memset( p_sys, 0, sizeof(*p_sys) );
 
diff --git a/modules/services_discovery/podcast.c b/modules/services_discovery/podcast.c
index f0b33c3..50efcc8 100644
--- a/modules/services_discovery/podcast.c
+++ b/modules/services_discovery/podcast.c
@@ -106,6 +106,8 @@ static int Open( vlc_object_t *p_this )
     services_discovery_t *p_sd = ( services_discovery_t* )p_this;
     services_discovery_sys_t *p_sys  = malloc(
                                     sizeof( services_discovery_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
 
     p_sys->i_urls = 0;
     p_sys->ppsz_urls = NULL;
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index d591248..317f02a 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -294,6 +294,8 @@ static int Open( vlc_object_t *p_this )
     services_discovery_t *p_sd = ( services_discovery_t* )p_this;
     services_discovery_sys_t *p_sys  = (services_discovery_sys_t *)
                                 malloc( sizeof( services_discovery_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
 
     p_sys->i_timeout = var_CreateGetInteger( p_sd, "sap-timeout" );
 




More information about the vlc-devel mailing list