Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Uninitialized stack data ends up in qmf_state

Open Beginner friendly
#155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Read mp3d_synth_granule in minimp3.h around the linked lines, focusing on how scratch.syn is populated and copied into qmf_state. Confirm the uninitialized values with a state comparison or Valgrind, then check that zeroing the unwritten region makes saved states deterministic while leaving PCM output unchanged.

Written by the indexing model from the issue text.

Description

Hi,

I'm working on a project that uses minimp3 as a dependency, and I need to be able to save and restore (serialize/deserialize) the decoder state. While writing a test for that, I noticed that the same input gave different saved states from one run to the next. Valgrind tracked it down to this:

In mp3d_synth_granule (here), lins points into scratch.syn, which is a stack buffer. The last mp3d_synth call doesn't write every float in its block, but the copy at the end puts that whole region into qmf_state. That means a few uninitialized stack values get stored in the decoder on every granule (15 floats in mono, 30 in stereo).

They get overwritten before they're ever read, so the PCM output isn't affected and no one would ever notice it normally. It's only a problem when you need code side deterministic behavior, like comparing or hashing decoder states.

I patched my local copy like this:

     memcpy(lins, qmf_state, sizeof(float)*15*64);
+    memset(lins + 15*64, 0, sizeof(float)*64*nbands);
 
     for (i = 0; i < nbands; i += 2)

With that, the output is unchanged and the state is identical between runs.

It would be nice to have this fixed upstream. Happy to open a PR if that's easier.

Thanks

Dominant language
C
Stars
2k
Forks
271
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lieff/minimp3

All issues in lieff/minimp3

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.