Skip to content

Fix calling memcpy with a null pointer from MatroskaParser#571

Merged
arch1t3cht merged 2 commits intoTypesettingTools:masterfrom
filip-hejsek:memcpy_null_fix
Mar 2, 2026
Merged

Fix calling memcpy with a null pointer from MatroskaParser#571
arch1t3cht merged 2 commits intoTypesettingTools:masterfrom
filip-hejsek:memcpy_null_fix

Conversation

@filip-hejsek
Copy link
Contributor

Fixes #562.

Fix taken from mojie126@42f2aeb. The code seems reasonable to me. Fixing it like this defeats the original purpose of calling the read function with zero size and null buffer, but that original purpose has already been lost anyway because the call just ends up here:

static char dummy = 0;
if (length == 0) return &dummy;

The purpose appears to be to load the pages into cache. This is not really essential and avoiding UB is more important, but I've added a FIXME to MatroskaParser noting that it doesn't work. I don't really feel like digging deeper into the MatroskaParser code to figure out a better solution.

@filip-hejsek filip-hejsek marked this pull request as ready for review March 2, 2026 16:48
@arch1t3cht arch1t3cht merged commit 2aa8cc2 into TypesettingTools:master Mar 2, 2026
7 checks passed
@filip-hejsek filip-hejsek deleted the memcpy_null_fix branch March 2, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memcpy called with null pointer from MatroskaParser

2 participants