Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
f36b9bc6
Commit
f36b9bc6
authored
Feb 20, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HTTP interface art: use make_path and fix a few memory errors
parent
a85ee2ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
35 deletions
+38
-35
modules/control/http/http.c
modules/control/http/http.c
+38
-35
No files found.
modules/control/http/http.c
View file @
f36b9bc6
...
@@ -798,53 +798,56 @@ int ArtCallback( httpd_handler_sys_t *p_args,
...
@@ -798,53 +798,56 @@ int ArtCallback( httpd_handler_sys_t *p_args,
psz_art
=
input_item_GetArtURL
(
p_item
);
psz_art
=
input_item_GetArtURL
(
p_item
);
}
}
if
(
psz_art
&&
!
strncmp
(
psz_art
,
"file://"
,
strlen
(
"file://"
)
)
&&
if
(
psz_art
)
decode_URI
(
psz_art
+
7
)
)
{
{
FILE
*
f
;
char
*
psz
=
make_path
(
psz_art
);
char
*
psz_ext
;
free
(
psz_art
);
char
*
psz_header
;
psz_art
=
psz
;
char
*
p_data
=
NULL
;
}
int
i_header_size
,
i_data
;
if
(
(
f
=
vlc_fopen
(
psz_art
+
strlen
(
"file://"
),
"r"
)
)
==
NULL
)
if
(
psz_art
==
NULL
)
{
{
msg_Dbg
(
p_intf
,
"Couldn't open album art file %s"
,
msg_Dbg
(
p_intf
,
"No album art found"
);
psz_art
+
strlen
(
"file://"
)
);
Callback404
(
&
p_args
->
file
,
(
char
**
)
pp_data
,
pi_data
);
Callback404
(
&
p_args
->
file
,
(
char
**
)
pp_data
,
pi_data
);
return
VLC_SUCCESS
;
free
(
psz_art
);
}
return
VLC_SUCCESS
;
}
FileLoad
(
f
,
&
p_data
,
&
i_data
);
FILE
*
f
=
vlc_fopen
(
psz_art
,
"r"
);
if
(
f
==
NULL
)
{
msg_Dbg
(
p_intf
,
"Couldn't open album art file %s"
,
psz_art
);
Callback404
(
&
p_args
->
file
,
(
char
**
)
pp_data
,
pi_data
);
free
(
psz_art
);
return
VLC_SUCCESS
;
}
free
(
psz_art
);
fclose
(
f
);
char
*
p_data
=
NULL
;
int
i_data
;
FileLoad
(
f
,
&
p_data
,
&
i_data
);
fclose
(
f
);
psz_ext
=
strrchr
(
psz_art
,
'.'
);
char
*
psz_ext
=
strrchr
(
psz_art
,
'.'
);
if
(
psz_ext
)
psz_ext
++
;
if
(
psz_ext
)
psz_ext
++
;
#define HEADER "Content-Type: image/%s\n" \
#define HEADER "Content-Type: image/%s\n" \
"Content-Length: %d\n" \
"Content-Length: %d\n" \
"\n"
"\n"
i_header_size
=
asprintf
(
&
psz_header
,
HEADER
,
psz_ext
,
i_data
);
char
*
psz_header
;
int
i_header_size
=
asprintf
(
&
psz_header
,
HEADER
,
psz_ext
,
i_data
);
#undef HEADER
#undef HEADER
if
(
likely
(
i_header_size
!=
-
1
)
)
assert
(
i_header_size
!=
-
1
);
*
pi_data
=
i_header_size
+
i_data
;
*
pp_data
=
(
uint8_t
*
)
malloc
(
*
pi_data
);
memcpy
(
*
pp_data
,
psz_header
,
i_header_size
);
memcpy
(
*
pp_data
+
i_header_size
,
p_data
,
i_data
);
free
(
psz_header
);
free
(
p_data
);
}
else
{
{
msg_Dbg
(
p_intf
,
"No album art found"
);
*
pp_data
=
malloc
(
i_header_size
+
i_data
);
Callback404
(
&
p_args
->
file
,
(
char
**
)
pp_data
,
pi_data
);
if
(
likely
(
*
pp_data
!=
NULL
)
)
{
*
pi_data
=
i_header_size
+
i_data
;
memcpy
(
*
pp_data
,
psz_header
,
i_header_size
);
memcpy
(
*
pp_data
+
i_header_size
,
p_data
,
i_data
);
}
free
(
psz_header
);
}
}
free
(
p_data
);
free
(
psz_art
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
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