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
2e64afca
Commit
2e64afca
authored
Aug 19, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/modplug: check InputStream::KnownSize()
parent
51cda0be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
+18
-13
ModplugDecoderPlugin.cxx
src/decoder/plugins/ModplugDecoderPlugin.cxx
+18
-13
No files found.
src/decoder/plugins/ModplugDecoderPlugin.cxx
View file @
2e64afca
...
...
@@ -54,24 +54,29 @@ modplug_decoder_init(const config_param ¶m)
static
WritableBuffer
<
uint8_t
>
mod_loadfile
(
Decoder
*
decoder
,
InputStream
&
is
)
{
const
InputStream
::
offset_type
size
=
is
.
GetSize
();
//known/unknown size, preallocate array, lets read in chunks
if
(
size
==
0
)
{
LogWarning
(
modplug_domain
,
"file is empty"
);
return
{
nullptr
,
0
};
}
const
bool
is_stream
=
!
is
.
KnownSize
();
if
(
size
>
MODPLUG_FILE_LIMIT
)
{
LogWarning
(
modplug_domain
,
"file too large"
);
return
{
nullptr
,
0
};
}
WritableBuffer
<
uint8_t
>
buffer
;
if
(
is_stream
)
buffer
.
size
=
MODPLUG_PREALLOC_BLOCK
;
else
{
const
auto
size
=
is
.
GetSize
();
if
(
size
==
0
)
{
LogWarning
(
modplug_domain
,
"file is empty"
);
return
{
nullptr
,
0
};
}
//known/unknown size, preallocate array, lets read in chunks
if
(
size
>
MODPLUG_FILE_LIMIT
)
{
LogWarning
(
modplug_domain
,
"file too large"
);
return
{
nullptr
,
0
};
}
const
bool
is_stream
=
size
<
0
;
buffer
.
size
=
size
;
}
WritableBuffer
<
uint8_t
>
buffer
;
buffer
.
size
=
is_stream
?
MODPLUG_PREALLOC_BLOCK
:
size
;
buffer
.
data
=
new
uint8_t
[
buffer
.
size
];
uint8_t
*
const
end
=
buffer
.
end
();
...
...
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