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
898978a6
Commit
898978a6
authored
Oct 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mp3: no "goto"
http://xkcd.com/292/
parent
28b47725
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
19 deletions
+36
-19
mp3_plugin.c
src/decoder/mp3_plugin.c
+36
-19
No files found.
src/decoder/mp3_plugin.c
View file @
898978a6
...
@@ -282,15 +282,18 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
...
@@ -282,15 +282,18 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
if
(
count
!=
tagsize
)
{
if
(
count
!=
tagsize
)
{
DEBUG
(
"mp3_decode: error parsing ID3 tag
\n
"
);
DEBUG
(
"mp3_decode: error parsing ID3 tag
\n
"
);
goto
fail
;
g_free
(
allocated
);
return
;
}
}
id3_data
=
allocated
;
id3_data
=
allocated
;
}
}
id3_tag
=
id3_tag_parse
(
id3_data
,
tagsize
);
id3_tag
=
id3_tag_parse
(
id3_data
,
tagsize
);
if
(
id3_tag
==
NULL
)
if
(
id3_tag
==
NULL
)
{
goto
fail
;
g_free
(
allocated
);
return
;
}
if
(
mpd_tag
)
{
if
(
mpd_tag
)
{
struct
tag
*
tmp_tag
=
tag_id3_import
(
id3_tag
);
struct
tag
*
tmp_tag
=
tag_id3_import
(
id3_tag
);
...
@@ -311,7 +314,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
...
@@ -311,7 +314,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
}
}
id3_tag_delete
(
id3_tag
);
id3_tag_delete
(
id3_tag
);
fail:
g_free
(
allocated
);
g_free
(
allocated
);
}
}
#endif
#endif
...
@@ -472,49 +475,65 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen)
...
@@ -472,49 +475,65 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen)
bitlen
=
*
oldbitlen
;
bitlen
=
*
oldbitlen
;
if
(
bitlen
<
16
)
goto
fail
;
if
(
bitlen
<
16
)
return
false
;
bits
=
mad_bit_read
(
ptr
,
16
);
bits
=
mad_bit_read
(
ptr
,
16
);
bitlen
-=
16
;
bitlen
-=
16
;
if
(
bits
==
XI_MAGIC
)
{
if
(
bits
==
XI_MAGIC
)
{
if
(
bitlen
<
16
)
goto
fail
;
if
(
bitlen
<
16
)
if
(
mad_bit_read
(
ptr
,
16
)
!=
NG_MAGIC
)
goto
fail
;
return
false
;
if
(
mad_bit_read
(
ptr
,
16
)
!=
NG_MAGIC
)
return
false
;
bitlen
-=
16
;
bitlen
-=
16
;
xing
->
magic
=
XING_MAGIC_XING
;
xing
->
magic
=
XING_MAGIC_XING
;
}
else
if
(
bits
==
IN_MAGIC
)
{
}
else
if
(
bits
==
IN_MAGIC
)
{
if
(
bitlen
<
16
)
goto
fail
;
if
(
bitlen
<
16
)
if
(
mad_bit_read
(
ptr
,
16
)
!=
FO_MAGIC
)
goto
fail
;
return
false
;
if
(
mad_bit_read
(
ptr
,
16
)
!=
FO_MAGIC
)
return
false
;
bitlen
-=
16
;
bitlen
-=
16
;
xing
->
magic
=
XING_MAGIC_INFO
;
xing
->
magic
=
XING_MAGIC_INFO
;
}
}
else
if
(
bits
==
NG_MAGIC
)
xing
->
magic
=
XING_MAGIC_XING
;
else
if
(
bits
==
NG_MAGIC
)
xing
->
magic
=
XING_MAGIC_XING
;
else
if
(
bits
==
FO_MAGIC
)
xing
->
magic
=
XING_MAGIC_INFO
;
else
if
(
bits
==
FO_MAGIC
)
xing
->
magic
=
XING_MAGIC_INFO
;
else
goto
fail
;
else
return
false
;
if
(
bitlen
<
32
)
goto
fail
;
if
(
bitlen
<
32
)
return
false
;
xing
->
flags
=
mad_bit_read
(
ptr
,
32
);
xing
->
flags
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
if
(
xing
->
flags
&
XING_FRAMES
)
{
if
(
xing
->
flags
&
XING_FRAMES
)
{
if
(
bitlen
<
32
)
goto
fail
;
if
(
bitlen
<
32
)
return
false
;
xing
->
frames
=
mad_bit_read
(
ptr
,
32
);
xing
->
frames
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
}
}
if
(
xing
->
flags
&
XING_BYTES
)
{
if
(
xing
->
flags
&
XING_BYTES
)
{
if
(
bitlen
<
32
)
goto
fail
;
if
(
bitlen
<
32
)
return
false
;
xing
->
bytes
=
mad_bit_read
(
ptr
,
32
);
xing
->
bytes
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
}
}
if
(
xing
->
flags
&
XING_TOC
)
{
if
(
xing
->
flags
&
XING_TOC
)
{
if
(
bitlen
<
800
)
goto
fail
;
if
(
bitlen
<
800
)
return
false
;
for
(
i
=
0
;
i
<
100
;
++
i
)
xing
->
toc
[
i
]
=
mad_bit_read
(
ptr
,
8
);
for
(
i
=
0
;
i
<
100
;
++
i
)
xing
->
toc
[
i
]
=
mad_bit_read
(
ptr
,
8
);
bitlen
-=
800
;
bitlen
-=
800
;
}
}
if
(
xing
->
flags
&
XING_SCALE
)
{
if
(
xing
->
flags
&
XING_SCALE
)
{
if
(
bitlen
<
32
)
goto
fail
;
if
(
bitlen
<
32
)
return
false
;
xing
->
scale
=
mad_bit_read
(
ptr
,
32
);
xing
->
scale
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
}
}
...
@@ -522,7 +541,8 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen)
...
@@ -522,7 +541,8 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen)
/* Make sure we consume no less than 120 bytes (960 bits) in hopes that
/* Make sure we consume no less than 120 bytes (960 bits) in hopes that
* the LAME tag is found there, and not right after the Xing header */
* the LAME tag is found there, and not right after the Xing header */
bitsleft
=
960
-
((
*
oldbitlen
)
-
bitlen
);
bitsleft
=
960
-
((
*
oldbitlen
)
-
bitlen
);
if
(
bitsleft
<
0
)
goto
fail
;
if
(
bitsleft
<
0
)
return
false
;
else
if
(
bitsleft
>
0
)
{
else
if
(
bitsleft
>
0
)
{
mad_bit_read
(
ptr
,
bitsleft
);
mad_bit_read
(
ptr
,
bitsleft
);
bitlen
-=
bitsleft
;
bitlen
-=
bitsleft
;
...
@@ -531,9 +551,6 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen)
...
@@ -531,9 +551,6 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen)
*
oldbitlen
=
bitlen
;
*
oldbitlen
=
bitlen
;
return
true
;
return
true
;
fail:
xing
->
flags
=
0
;
return
false
;
}
}
static
bool
static
bool
...
...
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