Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ab967462
Commit
ab967462
authored
Sep 16, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/{ApeLoader,Id3Load}: catch InputStream exceptions
parent
1bc553ea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
ApeLoader.cxx
src/tag/ApeLoader.cxx
+4
-1
Id3Load.cxx
src/tag/Id3Load.cxx
+28
-9
No files found.
src/tag/ApeLoader.cxx
View file @
ab967462
...
...
@@ -25,6 +25,7 @@
#include "util/Error.hxx"
#include <memory>
#include <stdexcept>
#include <stdint.h>
#include <assert.h>
...
...
@@ -41,7 +42,7 @@ struct ApeFooter {
bool
tag_ape_scan
(
InputStream
&
is
,
ApeTagCallback
callback
)
{
try
{
const
ScopeLock
protect
(
is
.
mutex
);
if
(
!
is
.
KnownSize
()
||
!
is
.
CheapSeeking
())
...
...
@@ -103,4 +104,6 @@ tag_ape_scan(InputStream &is, ApeTagCallback callback)
}
return
true
;
}
catch
(
const
std
::
runtime_error
&
)
{
return
false
;
}
src/tag/Id3Load.cxx
View file @
ab967462
...
...
@@ -29,6 +29,7 @@
#include <id3tag.h>
#include <algorithm>
#include <stdexcept>
static
constexpr
Domain
id3_domain
(
"id3"
);
...
...
@@ -43,7 +44,7 @@ tag_is_id3v1(struct id3_tag *tag)
static
long
get_id3v2_footer_size
(
InputStream
&
is
,
offset_type
offset
)
{
try
{
id3_byte_t
buf
[
ID3_TAG_QUERYSIZE
];
if
(
!
is
.
Seek
(
offset
,
IgnoreError
()))
return
0
;
...
...
@@ -52,11 +53,13 @@ get_id3v2_footer_size(InputStream &is, offset_type offset)
return
0
;
return
id3_tag_query
(
buf
,
sizeof
(
buf
));
}
catch
(
const
std
::
runtime_error
&
)
{
return
0
;
}
static
UniqueId3Tag
ReadId3Tag
(
InputStream
&
is
)
{
try
{
id3_byte_t
query_buffer
[
ID3_TAG_QUERYSIZE
];
if
(
!
is
.
ReadFull
(
query_buffer
,
sizeof
(
query_buffer
),
IgnoreError
()))
return
nullptr
;
...
...
@@ -84,40 +87,48 @@ ReadId3Tag(InputStream &is)
return
nullptr
;
return
UniqueId3Tag
(
id3_tag_parse
(
tag_buffer
.
get
(),
tag_size
));
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
static
UniqueId3Tag
ReadId3Tag
(
InputStream
&
is
,
offset_type
offset
)
{
try
{
if
(
!
is
.
Seek
(
offset
,
IgnoreError
()))
return
nullptr
;
return
ReadId3Tag
(
is
);
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
static
UniqueId3Tag
ReadId3v1Tag
(
InputStream
&
is
)
{
try
{
id3_byte_t
buffer
[
ID3V1_SIZE
];
if
(
is
.
Read
(
buffer
,
ID3V1_SIZE
,
IgnoreError
())
!=
ID3V1_SIZE
)
return
nullptr
;
return
UniqueId3Tag
(
id3_tag_parse
(
buffer
,
ID3V1_SIZE
));
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
static
UniqueId3Tag
ReadId3v1Tag
(
InputStream
&
is
,
offset_type
offset
)
{
try
{
if
(
!
is
.
Seek
(
offset
,
IgnoreError
()))
return
nullptr
;
return
ReadId3v1Tag
(
is
);
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
static
UniqueId3Tag
tag_id3_find_from_beginning
(
InputStream
&
is
)
{
try
{
auto
tag
=
ReadId3Tag
(
is
);
if
(
!
tag
)
{
return
nullptr
;
...
...
@@ -144,11 +155,13 @@ tag_id3_find_from_beginning(InputStream &is)
}
return
tag
;
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
static
UniqueId3Tag
tag_id3_find_from_end
(
InputStream
&
is
)
{
try
{
if
(
!
is
.
KnownSize
()
||
!
is
.
CheapSeeking
())
return
nullptr
;
...
...
@@ -183,11 +196,13 @@ tag_id3_find_from_end(InputStream &is)
/* We have an id3v2 tag, so ditch v1tag */
return
tag
;
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
static
UniqueId3Tag
tag_id3_riff_aiff_load
(
InputStream
&
is
)
{
try
{
size_t
size
=
riff_seek_id3
(
is
);
if
(
size
==
0
)
size
=
aiff_seek_id3
(
is
);
...
...
@@ -205,11 +220,13 @@ tag_id3_riff_aiff_load(InputStream &is)
}
return
UniqueId3Tag
(
id3_tag_parse
(
buffer
.
get
(),
size
));
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
UniqueId3Tag
tag_id3_load
(
InputStream
&
is
)
{
try
{
const
ScopeLock
protect
(
is
.
mutex
);
auto
tag
=
tag_id3_find_from_beginning
(
is
);
...
...
@@ -220,4 +237,6 @@ tag_id3_load(InputStream &is)
}
return
tag
;
}
catch
(
const
std
::
runtime_error
&
)
{
return
nullptr
;
}
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