From 829efb0501ed663e1a9e153c380c7f1aea3a18cd Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 21 Jul 2026 14:32:28 +0300
Subject: [PATCH] update dr_flac from mainstream (Jul.15, 2026)
(cherry picked from commit 93c41dc52afcc3b9753b146ca8524de958107590)
---
src/codecs/dr_libs/dr_flac.h | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/src/codecs/dr_libs/dr_flac.h b/src/codecs/dr_libs/dr_flac.h
index 72bc6b76..3a234ed2 100644
--- a/src/codecs/dr_libs/dr_flac.h
+++ b/src/codecs/dr_libs/dr_flac.h
@@ -709,6 +709,9 @@ onRead (in)
onSeek (in)
The function to call when the read position of the client data needs to move.
+onTell (in)
+ The function to call when the read position of the client needs to be queried.
+
pUserData (in, optional)
A pointer to application defined data that will be passed to onRead and onSeek.
@@ -759,6 +762,9 @@ onRead (in)
onSeek (in)
The function to call when the read position of the client data needs to move.
+onTell (in)
+ The function to call when the read position of the client needs to be queried.
+
container (in)
Whether or not the FLAC stream is encapsulated using standard FLAC encapsulation or Ogg encapsulation.
@@ -800,6 +806,9 @@ onRead (in)
onSeek (in)
The function to call when the read position of the client data needs to move.
+onTell (in)
+ The function to call when the read position of the client needs to be queried.
+
onMeta (in)
The function to call for every metadata block.
@@ -5369,6 +5378,7 @@ static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame,
{
drflac_subframe* pSubframe;
drflac_uint32 subframeBitsPerSample;
+ drflac_bool32 decodeResult;
DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(frame != NULL);
@@ -5415,28 +5425,28 @@ static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame,
{
case DRFLAC_SUBFRAME_CONSTANT:
{
- drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
+ decodeResult = drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
} break;
case DRFLAC_SUBFRAME_VERBATIM:
{
- drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
+ decodeResult = drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
} break;
case DRFLAC_SUBFRAME_FIXED:
{
- drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
+ decodeResult = drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
} break;
case DRFLAC_SUBFRAME_LPC:
{
- drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
+ decodeResult = drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
} break;
- default: return DRFLAC_FALSE;
+ default: decodeResult = DRFLAC_FALSE;
}
- return DRFLAC_TRUE;
+ return decodeResult;
}
static drflac_bool32 drflac__seek_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex)
@@ -6445,7 +6455,7 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
hasKnownFileSize = DRFLAC_TRUE;
}
- onSeek(pUserData, runningFilePos, DRFLAC_SEEK_SET);
+ onSeek(pUserData, (int)runningFilePos, DRFLAC_SEEK_SET); /* Safe cast because runningFilePos should always be 42 at this point. */
}
}
@@ -6508,10 +6518,12 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
drflac_uint32 seekpointCount;
drflac_uint32 iSeekpoint;
void* pRawData;
+ size_t rawDataSize;
seekpointCount = blockSize/DRFLAC_SEEKPOINT_SIZE_IN_BYTES;
+ rawDataSize = seekpointCount * sizeof(drflac_seekpoint);
- pRawData = drflac__malloc_from_callbacks(seekpointCount * sizeof(drflac_seekpoint), pAllocationCallbacks);
+ pRawData = drflac__malloc_from_callbacks(rawDataSize, pAllocationCallbacks);
if (pRawData == NULL) {
return DRFLAC_FALSE;
}
@@ -6532,7 +6544,7 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
}
metadata.pRawData = pRawData;
- metadata.rawDataSize = blockSize;
+ metadata.rawDataSize = rawDataSize;
metadata.data.seektable.seekpointCount = seekpointCount;
metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
@@ -12206,6 +12218,7 @@ REVISION HISTORY
v0.13.4 - TBD
- Add a bounds check when allocating memory during metadata processing.
- Fix a possible overflow error when parsing picture metadata.
+ - Fix an with seek point parsing.
v0.13.3 - 2026-01-17
- Fix a compiler compatibility issue with some inlined assembly.