Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
502e723f
Commit
502e723f
authored
Aug 15, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input: fix vlc_attachment_New() error handling
Also use size_t for the size.
parent
b2c77d44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
20 deletions
+26
-20
include/vlc_input.h
include/vlc_input.h
+26
-20
No files found.
include/vlc_input.h
View file @
502e723f
...
...
@@ -161,48 +161,54 @@ struct input_attachment_t
char
*
psz_mime
;
char
*
psz_description
;
int
i_data
;
size_t
i_data
;
void
*
p_data
;
};
static
inline
void
vlc_input_attachment_Delete
(
input_attachment_t
*
a
)
{
if
(
!
a
)
return
;
free
(
a
->
p_data
);
free
(
a
->
psz_description
);
free
(
a
->
psz_mime
);
free
(
a
->
psz_name
);
free
(
a
);
}
static
inline
input_attachment_t
*
vlc_input_attachment_New
(
const
char
*
psz_name
,
const
char
*
psz_mime
,
const
char
*
psz_description
,
const
void
*
p_data
,
in
t
i_data
)
size_
t
i_data
)
{
input_attachment_t
*
a
=
(
input_attachment_t
*
)
malloc
(
sizeof
(
input_attachment_t
)
);
if
(
!
a
)
input_attachment_t
*
a
=
(
input_attachment_t
*
)
malloc
(
sizeof
(
*
a
)
);
if
(
unlikely
(
a
==
NULL
)
)
return
NULL
;
a
->
psz_name
=
strdup
(
psz_name
?
psz_name
:
""
);
a
->
psz_mime
=
strdup
(
psz_mime
?
psz_mime
:
""
);
a
->
psz_description
=
strdup
(
psz_description
?
psz_description
:
""
);
a
->
i_data
=
i_data
;
a
->
p_data
=
NULL
;
if
(
i_data
>
0
)
a
->
p_data
=
malloc
(
i_data
);
if
(
i_data
>
0
&&
likely
(
p_data
!=
NULL
)
)
memcpy
(
a
->
p_data
,
p_data
,
i_data
);
if
(
unlikely
(
a
->
psz_name
==
NULL
||
a
->
psz_mime
==
NULL
||
a
->
psz_description
||
(
i_data
>
0
&&
a
->
p_data
==
NULL
))
)
{
a
->
p_data
=
malloc
(
i_data
);
if
(
a
->
p_data
&&
p_data
)
memcpy
(
a
->
p_data
,
p_data
,
i_data
);
vlc_input_attachment_Delete
(
a
);
a
=
NULL
;
}
return
a
;
}
static
inline
input_attachment_t
*
vlc_input_attachment_Duplicate
(
const
input_attachment_t
*
a
)
{
return
vlc_input_attachment_New
(
a
->
psz_name
,
a
->
psz_mime
,
a
->
psz_description
,
a
->
p_data
,
a
->
i_data
);
}
static
inline
void
vlc_input_attachment_Delete
(
input_attachment_t
*
a
)
{
if
(
!
a
)
return
;
free
(
a
->
psz_name
);
free
(
a
->
psz_mime
);
free
(
a
->
psz_description
);
free
(
a
->
p_data
);
free
(
a
);
}
/*****************************************************************************
* input defines/constants.
...
...
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