Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
MyCard
miniaudio
Commits
63df16a2
Commit
63df16a2
authored
Jan 13, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some safety checks when reading from data sources.
parent
7a8ff122
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
miniaudio.h
miniaudio.h
+7
-0
research/miniaudio_engine.c
research/miniaudio_engine.c
+1
-1
research/miniaudio_engine.h
research/miniaudio_engine.h
+15
-0
No files found.
miniaudio.h
View file @
63df16a2
...
@@ -43130,6 +43130,12 @@ MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format)
...
@@ -43130,6 +43130,12 @@ MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format)
MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead, ma_bool32 loop)
MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead, ma_bool32 loop)
{
{
ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
/* Safety. */
if (pFramesRead != NULL) {
*pFramesRead = 0;
}
if (pCallbacks == NULL) {
if (pCallbacks == NULL) {
return MA_INVALID_ARGS;
return MA_INVALID_ARGS;
}
}
...
@@ -64686,6 +64692,7 @@ REVISION HISTORY
...
@@ -64686,6 +64692,7 @@ REVISION HISTORY
================
================
v0.10.31 - TBD
v0.10.31 - TBD
- Make some functions const correct.
- Make some functions const correct.
- Update ma_data_source_read_pcm_frames() to initialize pFramesRead to 0 for safety.
v0.10.30 - 2021-01-10
v0.10.30 - 2021-01-10
- Fix a crash in ma_audio_buffer_read_pcm_frames().
- Fix a crash in ma_audio_buffer_read_pcm_frames().
research/miniaudio_engine.c
View file @
63df16a2
...
@@ -78,7 +78,7 @@ int main(int argc, char** argv)
...
@@ -78,7 +78,7 @@ int main(int argc, char** argv)
loadNotification
.
cb
.
onSignal
=
on_sound_loaded
;
loadNotification
.
cb
.
onSignal
=
on_sound_loaded
;
loadNotification
.
pSound
=
&
sound
;
loadNotification
.
pSound
=
&
sound
;
result
=
ma_sound_init_from_file
(
&
engine
,
argv
[
1
],
MA_DATA_SOURCE_FLAG_DECODE
|
MA_DATA_SOURCE_FLAG_ASYNC
/*| MA_DATA_SOURCE_FLAG_STREAM*/
,
&
loadNotification
,
NULL
,
&
sound
);
result
=
ma_sound_init_from_file
(
&
engine
,
argv
[
1
],
/*MA_DATA_SOURCE_FLAG_DECODE | MA_DATA_SOURCE_FLAG_ASYNC |*/
MA_DATA_SOURCE_FLAG_STREAM
,
&
loadNotification
,
NULL
,
&
sound
);
if
(
result
!=
MA_SUCCESS
)
{
if
(
result
!=
MA_SUCCESS
)
{
printf
(
"Failed to load sound: %s
\n
"
,
argv
[
1
]);
printf
(
"Failed to load sound: %s
\n
"
,
argv
[
1
]);
ma_engine_uninit
(
&
engine
);
ma_engine_uninit
(
&
engine
);
...
...
research/miniaudio_engine.h
View file @
63df16a2
...
@@ -5976,6 +5976,11 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man
...
@@ -5976,6 +5976,11 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man
ma_bool32
isLooping
;
ma_bool32
isLooping
;
ma_bool32
skipBusyCheck
=
MA_FALSE
;
ma_bool32
skipBusyCheck
=
MA_FALSE
;
/* Safety. */
if
(
pFramesRead
!=
NULL
)
{
*
pFramesRead
=
0
;
}
/*
/*
We cannot be using the data buffer after it's been uninitialized. If you trigger this assert it means you're trying to read from the data buffer after
We cannot be using the data buffer after it's been uninitialized. If you trigger this assert it means you're trying to read from the data buffer after
it's been uninitialized or is in the process of uninitializing.
it's been uninitialized or is in the process of uninitializing.
...
@@ -6617,6 +6622,11 @@ MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_man
...
@@ -6617,6 +6622,11 @@ MA_API ma_result ma_resource_manager_data_stream_read_pcm_frames(ma_resource_man
ma_format
format
;
ma_format
format
;
ma_uint32
channels
;
ma_uint32
channels
;
/* Safety. */
if
(
pFramesRead
!=
NULL
)
{
*
pFramesRead
=
0
;
}
/* We cannot be using the data source after it's been uninitialized. */
/* We cannot be using the data source after it's been uninitialized. */
MA_ASSERT
(
ma_resource_manager_data_stream_result
(
pDataStream
)
!=
MA_UNAVAILABLE
);
MA_ASSERT
(
ma_resource_manager_data_stream_result
(
pDataStream
)
!=
MA_UNAVAILABLE
);
...
@@ -7031,6 +7041,11 @@ MA_API ma_result ma_resource_manager_data_source_uninit(ma_resource_manager_data
...
@@ -7031,6 +7041,11 @@ MA_API ma_result ma_resource_manager_data_source_uninit(ma_resource_manager_data
MA_API
ma_result
ma_resource_manager_data_source_read_pcm_frames
(
ma_resource_manager_data_source
*
pDataSource
,
void
*
pFramesOut
,
ma_uint64
frameCount
,
ma_uint64
*
pFramesRead
)
MA_API
ma_result
ma_resource_manager_data_source_read_pcm_frames
(
ma_resource_manager_data_source
*
pDataSource
,
void
*
pFramesOut
,
ma_uint64
frameCount
,
ma_uint64
*
pFramesRead
)
{
{
/* Safety. */
if
(
pFramesRead
!=
NULL
)
{
*
pFramesRead
=
0
;
}
if
(
pDataSource
==
NULL
)
{
if
(
pDataSource
==
NULL
)
{
return
MA_INVALID_ARGS
;
return
MA_INVALID_ARGS
;
}
}
...
...
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