Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
59b025e3
Commit
59b025e3
authored
Dec 05, 2009
by
JP Dinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more assert()s for unchecked malloc().
parent
15643af1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
src/modules/cache.c
src/modules/cache.c
+7
-0
src/network/httpd.c
src/network/httpd.c
+16
-0
No files found.
src/modules/cache.c
View file @
59b025e3
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_common.h>
#include "libvlc.h"
#include "libvlc.h"
#include <assert.h>
#include <stdlib.h>
/* free(), strtol() */
#include <stdlib.h>
/* free(), strtol() */
#include <stdio.h>
/* sprintf() */
#include <stdio.h>
/* sprintf() */
#include <string.h>
/* strdup() */
#include <string.h>
/* strdup() */
...
@@ -228,8 +229,11 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, bool b_delete )
...
@@ -228,8 +229,11 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, bool b_delete )
}
}
if
(
i_cache
)
if
(
i_cache
)
{
pp_cache
=
p_bank
->
pp_loaded_cache
=
pp_cache
=
p_bank
->
pp_loaded_cache
=
malloc
(
i_cache
*
sizeof
(
void
*
)
);
malloc
(
i_cache
*
sizeof
(
void
*
)
);
assert
(
pp_cache
);
}
#define LOAD_IMMEDIATE(a) \
#define LOAD_IMMEDIATE(a) \
if( fread( (void *)&a, sizeof(char), sizeof(a), file ) != sizeof(a) ) goto error
if( fread( (void *)&a, sizeof(char), sizeof(a), file ) != sizeof(a) ) goto error
...
@@ -259,6 +263,7 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, bool b_delete )
...
@@ -259,6 +263,7 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, bool b_delete )
int
i_submodules
;
int
i_submodules
;
pp_cache
[
i
]
=
malloc
(
sizeof
(
module_cache_t
)
);
pp_cache
[
i
]
=
malloc
(
sizeof
(
module_cache_t
)
);
assert
(
pp_cache
[
i
]
);
p_bank
->
i_loaded_cache
++
;
p_bank
->
i_loaded_cache
++
;
/* Load common info */
/* Load common info */
...
@@ -430,8 +435,10 @@ static int CacheLoadConfig( module_t *p_module, FILE *file )
...
@@ -430,8 +435,10 @@ static int CacheLoadConfig( module_t *p_module, FILE *file )
{
{
p_module
->
p_config
[
i
].
ppf_action
=
p_module
->
p_config
[
i
].
ppf_action
=
malloc
(
p_module
->
p_config
[
i
].
i_action
*
sizeof
(
void
*
)
);
malloc
(
p_module
->
p_config
[
i
].
i_action
*
sizeof
(
void
*
)
);
assert
(
p_module
->
p_config
[
i
].
ppf_action
);
p_module
->
p_config
[
i
].
ppsz_action_text
=
p_module
->
p_config
[
i
].
ppsz_action_text
=
malloc
(
p_module
->
p_config
[
i
].
i_action
*
sizeof
(
char
*
)
);
malloc
(
p_module
->
p_config
[
i
].
i_action
*
sizeof
(
char
*
)
);
assert
(
p_module
->
p_config
[
i
].
ppsz_action_text
);
for
(
int
j
=
0
;
j
<
p_module
->
p_config
[
i
].
i_action
;
j
++
)
for
(
int
j
=
0
;
j
<
p_module
->
p_config
[
i
].
i_action
;
j
++
)
{
{
...
...
src/network/httpd.c
View file @
59b025e3
...
@@ -461,6 +461,7 @@ httpd_file_t *httpd_FileNew( httpd_host_t *host,
...
@@ -461,6 +461,7 @@ httpd_file_t *httpd_FileNew( httpd_host_t *host,
httpd_file_sys_t
*
p_sys
)
httpd_file_sys_t
*
p_sys
)
{
{
httpd_file_t
*
file
=
malloc
(
sizeof
(
httpd_file_t
)
);
httpd_file_t
*
file
=
malloc
(
sizeof
(
httpd_file_t
)
);
assert
(
file
);
if
(
(
file
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url
,
psz_user
,
if
(
(
file
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url
,
psz_user
,
psz_password
,
p_acl
)
psz_password
,
p_acl
)
...
@@ -593,6 +594,7 @@ httpd_HandlerCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
...
@@ -593,6 +594,7 @@ httpd_HandlerCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
answer
->
i_body
=
sizeof
(
"HTTP/1.0 xxx
\r\n
"
)
answer
->
i_body
=
sizeof
(
"HTTP/1.0 xxx
\r\n
"
)
+
strlen
(
psz_status
)
+
i_headers
-
1
;
+
strlen
(
psz_status
)
+
i_headers
-
1
;
psz_new
=
(
char
*
)
malloc
(
answer
->
i_body
+
1
);
psz_new
=
(
char
*
)
malloc
(
answer
->
i_body
+
1
);
assert
(
psz_new
);
sprintf
(
psz_new
,
"HTTP/1.0 %03d %s
\r\n
"
,
i_status
,
psz_status
);
sprintf
(
psz_new
,
"HTTP/1.0 %03d %s
\r\n
"
,
i_status
,
psz_status
);
memcpy
(
&
psz_new
[
strlen
(
psz_new
)],
psz_headers
,
i_headers
);
memcpy
(
&
psz_new
[
strlen
(
psz_new
)],
psz_headers
,
i_headers
);
free
(
answer
->
p_body
);
free
(
answer
->
p_body
);
...
@@ -610,6 +612,7 @@ httpd_handler_t *httpd_HandlerNew( httpd_host_t *host, const char *psz_url,
...
@@ -610,6 +612,7 @@ httpd_handler_t *httpd_HandlerNew( httpd_host_t *host, const char *psz_url,
httpd_handler_sys_t
*
p_sys
)
httpd_handler_sys_t
*
p_sys
)
{
{
httpd_handler_t
*
handler
=
malloc
(
sizeof
(
httpd_handler_t
)
);
httpd_handler_t
*
handler
=
malloc
(
sizeof
(
httpd_handler_t
)
);
assert
(
handler
);
if
(
(
handler
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url
,
psz_user
,
if
(
(
handler
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url
,
psz_user
,
psz_password
,
p_acl
)
psz_password
,
p_acl
)
...
@@ -681,6 +684,7 @@ httpd_redirect_t *httpd_RedirectNew( httpd_host_t *host, const char *psz_url_dst
...
@@ -681,6 +684,7 @@ httpd_redirect_t *httpd_RedirectNew( httpd_host_t *host, const char *psz_url_dst
const
char
*
psz_url_src
)
const
char
*
psz_url_src
)
{
{
httpd_redirect_t
*
rdir
=
malloc
(
sizeof
(
httpd_redirect_t
)
);
httpd_redirect_t
*
rdir
=
malloc
(
sizeof
(
httpd_redirect_t
)
);
assert
(
rdir
);
if
(
!
(
rdir
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url_src
,
NULL
,
NULL
,
NULL
)
)
)
if
(
!
(
rdir
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url_src
,
NULL
,
NULL
,
NULL
)
)
)
{
{
...
@@ -787,6 +791,7 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
...
@@ -787,6 +791,7 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
answer
->
i_body
=
i_write
;
answer
->
i_body
=
i_write
;
answer
->
p_body
=
malloc
(
i_write
);
answer
->
p_body
=
malloc
(
i_write
);
assert
(
answer
->
p_body
);
memcpy
(
answer
->
p_body
,
&
stream
->
p_buffer
[
i_pos
],
i_write
);
memcpy
(
answer
->
p_body
,
&
stream
->
p_buffer
[
i_pos
],
i_write
);
answer
->
i_body_offset
+=
i_write
;
answer
->
i_body_offset
+=
i_write
;
...
@@ -810,6 +815,7 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
...
@@ -810,6 +815,7 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
{
{
answer
->
i_body
=
stream
->
i_header
;
answer
->
i_body
=
stream
->
i_header
;
answer
->
p_body
=
malloc
(
stream
->
i_header
);
answer
->
p_body
=
malloc
(
stream
->
i_header
);
assert
(
answer
->
p_body
);
memcpy
(
answer
->
p_body
,
stream
->
p_header
,
stream
->
i_header
);
memcpy
(
answer
->
p_body
,
stream
->
p_header
,
stream
->
i_header
);
}
}
answer
->
i_body_offset
=
stream
->
i_buffer_last_pos
;
answer
->
i_body_offset
=
stream
->
i_buffer_last_pos
;
...
@@ -863,6 +869,7 @@ httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
...
@@ -863,6 +869,7 @@ httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
const
vlc_acl_t
*
p_acl
)
const
vlc_acl_t
*
p_acl
)
{
{
httpd_stream_t
*
stream
=
malloc
(
sizeof
(
httpd_stream_t
)
);
httpd_stream_t
*
stream
=
malloc
(
sizeof
(
httpd_stream_t
)
);
assert
(
stream
);
if
(
(
stream
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url
,
psz_user
,
if
(
(
stream
->
url
=
httpd_UrlNewUnique
(
host
,
psz_url
,
psz_user
,
psz_password
,
p_acl
)
psz_password
,
p_acl
)
...
@@ -884,6 +891,7 @@ httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
...
@@ -884,6 +891,7 @@ httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
stream
->
p_header
=
NULL
;
stream
->
p_header
=
NULL
;
stream
->
i_buffer_size
=
5000000
;
/* 5 Mo per stream */
stream
->
i_buffer_size
=
5000000
;
/* 5 Mo per stream */
stream
->
p_buffer
=
malloc
(
stream
->
i_buffer_size
);
stream
->
p_buffer
=
malloc
(
stream
->
i_buffer_size
);
assert
(
stream
->
p_buffer
);
/* We set to 1 to make life simpler
/* We set to 1 to make life simpler
* (this way i_body_offset can never be 0) */
* (this way i_body_offset can never be 0) */
stream
->
i_buffer_pos
=
1
;
stream
->
i_buffer_pos
=
1
;
...
@@ -909,6 +917,7 @@ int httpd_StreamHeader( httpd_stream_t *stream, uint8_t *p_data, int i_data )
...
@@ -909,6 +917,7 @@ int httpd_StreamHeader( httpd_stream_t *stream, uint8_t *p_data, int i_data )
if
(
i_data
>
0
)
if
(
i_data
>
0
)
{
{
stream
->
p_header
=
malloc
(
i_data
);
stream
->
p_header
=
malloc
(
i_data
);
assert
(
stream
->
p_header
);
memcpy
(
stream
->
p_header
,
p_data
,
i_data
);
memcpy
(
stream
->
p_header
,
p_data
,
i_data
);
}
}
vlc_mutex_unlock
(
&
stream
->
lock
);
vlc_mutex_unlock
(
&
stream
->
lock
);
...
@@ -1239,6 +1248,7 @@ static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, const char *psz_url
...
@@ -1239,6 +1248,7 @@ static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, const char *psz_url
}
}
url
=
malloc
(
sizeof
(
httpd_url_t
)
);
url
=
malloc
(
sizeof
(
httpd_url_t
)
);
assert
(
url
);
url
->
host
=
host
;
url
->
host
=
host
;
vlc_mutex_init
(
&
url
->
lock
);
vlc_mutex_init
(
&
url
->
lock
);
...
@@ -1407,6 +1417,7 @@ static void httpd_ClientInit( httpd_client_t *cl, mtime_t now )
...
@@ -1407,6 +1417,7 @@ static void httpd_ClientInit( httpd_client_t *cl, mtime_t now )
cl
->
i_buffer_size
=
HTTPD_CL_BUFSIZE
;
cl
->
i_buffer_size
=
HTTPD_CL_BUFSIZE
;
cl
->
i_buffer
=
0
;
cl
->
i_buffer
=
0
;
cl
->
p_buffer
=
malloc
(
cl
->
i_buffer_size
);
cl
->
p_buffer
=
malloc
(
cl
->
i_buffer_size
);
assert
(
cl
->
p_buffer
);
cl
->
i_mode
=
HTTPD_CLIENT_FILE
;
cl
->
i_mode
=
HTTPD_CLIENT_FILE
;
cl
->
b_read_waiting
=
false
;
cl
->
b_read_waiting
=
false
;
...
@@ -1555,6 +1566,7 @@ static void httpd_ClientRecv( httpd_client_t *cl )
...
@@ -1555,6 +1566,7 @@ static void httpd_ClientRecv( httpd_client_t *cl )
cl
->
query
.
i_channel
=
cl
->
p_buffer
[
1
];
cl
->
query
.
i_channel
=
cl
->
p_buffer
[
1
];
cl
->
query
.
i_body
=
(
cl
->
p_buffer
[
2
]
<<
8
)
|
cl
->
p_buffer
[
3
];
cl
->
query
.
i_body
=
(
cl
->
p_buffer
[
2
]
<<
8
)
|
cl
->
p_buffer
[
3
];
cl
->
query
.
p_body
=
malloc
(
cl
->
query
.
i_body
);
cl
->
query
.
p_body
=
malloc
(
cl
->
query
.
i_body
);
assert
(
cl
->
query
.
p_body
);
cl
->
i_buffer
-=
4
;
cl
->
i_buffer
-=
4
;
memcpy
(
cl
->
query
.
p_body
,
cl
->
p_buffer
+
4
,
cl
->
i_buffer
);
memcpy
(
cl
->
query
.
p_body
,
cl
->
p_buffer
+
4
,
cl
->
i_buffer
);
}
}
...
@@ -1836,6 +1848,7 @@ static void httpd_ClientRecv( httpd_client_t *cl )
...
@@ -1836,6 +1848,7 @@ static void httpd_ClientRecv( httpd_client_t *cl )
* request and close the connection
* request and close the connection
* to mark and of body (probably only RTSP) */
* to mark and of body (probably only RTSP) */
cl
->
query
.
p_body
=
malloc
(
cl
->
query
.
i_body
);
cl
->
query
.
p_body
=
malloc
(
cl
->
query
.
i_body
);
assert
(
cl
->
query
.
p_body
);
cl
->
i_buffer
=
0
;
cl
->
i_buffer
=
0
;
}
}
else
else
...
@@ -1924,6 +1937,7 @@ static void httpd_ClientSend( httpd_client_t *cl )
...
@@ -1924,6 +1937,7 @@ static void httpd_ClientSend( httpd_client_t *cl )
cl
->
i_buffer_size
=
i_size
;
cl
->
i_buffer_size
=
i_size
;
free
(
cl
->
p_buffer
);
free
(
cl
->
p_buffer
);
cl
->
p_buffer
=
malloc
(
i_size
);
cl
->
p_buffer
=
malloc
(
i_size
);
assert
(
cl
->
p_buffer
);
}
}
p
=
(
char
*
)
cl
->
p_buffer
;
p
=
(
char
*
)
cl
->
p_buffer
;
...
@@ -2367,6 +2381,7 @@ static void* httpd_HostThread( void *data )
...
@@ -2367,6 +2381,7 @@ static void* httpd_HostThread( void *data )
cl
->
i_buffer_size
=
1000
;
cl
->
i_buffer_size
=
1000
;
free
(
cl
->
p_buffer
);
free
(
cl
->
p_buffer
);
cl
->
p_buffer
=
malloc
(
cl
->
i_buffer_size
);
cl
->
p_buffer
=
malloc
(
cl
->
i_buffer_size
);
assert
(
cl
->
p_buffer
);
cl
->
i_state
=
HTTPD_CLIENT_RECEIVING
;
cl
->
i_state
=
HTTPD_CLIENT_RECEIVING
;
}
}
else
else
...
@@ -2385,6 +2400,7 @@ static void* httpd_HostThread( void *data )
...
@@ -2385,6 +2400,7 @@ static void* httpd_HostThread( void *data )
cl
->
i_buffer_size
=
1000
;
cl
->
i_buffer_size
=
1000
;
free
(
cl
->
p_buffer
);
free
(
cl
->
p_buffer
);
cl
->
p_buffer
=
malloc
(
cl
->
i_buffer_size
);
cl
->
p_buffer
=
malloc
(
cl
->
i_buffer_size
);
assert
(
cl
->
p_buffer
);
cl
->
i_state
=
HTTPD_CLIENT_RECEIVING
;
cl
->
i_state
=
HTTPD_CLIENT_RECEIVING
;
cl
->
b_read_waiting
=
false
;
cl
->
b_read_waiting
=
false
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment