Fix UB in void* pointer arithmetic and memory leak in VIF init - #1476
Open
StormBytePP wants to merge 1 commit into
Open
StormBytePP wants to merge 1 commit into
StormBytePP wants to merge 1 commit into
Conversation
StormBytePP
added a commit
to StormBytePP/vmaf
that referenced
this pull request
Mar 29, 2026
StormBytePP
added a commit
to StormBytePP/vmaf
that referenced
this pull request
Mar 29, 2026
10 tasks
Collaborator
|
Maybe just change the original type instead of casting N times? |
Contributor
Author
I wanted to maintain the original format so the changes introduced are minimal. Edit: There are some fields which still require explicit casts if original type is changed (at least in mingw) like: So I reverted because I think it is more readable to have all casted uniformly instead of sometimes and sometimes not. What do you think? |
StormBytePP
force-pushed
the
fix_UB_pointer_arith
branch
from
April 9, 2026 18:06
e1dba8e to
d3ef638
Compare
Signed-off-by: David C. Manuelda <StormByte@gmail.com>
StormBytePP
force-pushed
the
fix_UB_pointer_arith
branch
from
April 9, 2026 18:11
d3ef638 to
8384c37
Compare
StormBytePP
added a commit
to StormBytePP/vmaf
that referenced
this pull request
Aug 9, 2026
Signed-off-by: David C. Manuelda <StormByte@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix undefined behavior in
void*pointer arithmetic and a potential memory leak in the failure path ofvif_init().Changes
data += Noperations (which are UB onvoid*per C standard) with the portable and well-defined idiomdata = (char *)data + N.fail:label, we now free the original allocation pointer (s->public.buf.data) instead of the advanceddatapointer, preventing a memory leak whenvmaf_feature_name_dict_from_provided_features()fails.Why
void*aschar*for arithmetic), which is not guaranteed by the C standard and can break under strict conformance or aggressive optimizers.The memory layout and runtime behavior remain identical — only the correctness and portability are improved.
No functional change, only standard corrections.