Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible double-free of temporary indices buffer in compressMG1.c #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

musicinmybrain
Copy link

This appears to be a clear-cut case of accidentally calling free on a dangling pointer.

GCC reported:

compressMG1.c: In function ‘_ctmCompressMesh_MG1’: compressMG1.c:188:5: warning: pointer ‘indices_45’ may be used after ‘free’ [-Wuse-after-free]
  188 |     free((void *) indices);
      |     ^~~~~~~~~~~~~~~~~~~~~~
compressMG1.c:179:3: note: call to ‘free’ here
  179 |   free((void *) indices);
      |   ^~~~~~~~~~~~~~~~~~~~~~

and indeed, the conditional call to free removed in this PR appears a few lines after an unconditional free in

free((void *) indices);

GCC reported:

compressMG1.c: In function ‘_ctmCompressMesh_MG1’:
compressMG1.c:188:5: warning: pointer ‘indices_45’ may be used after ‘free’ [-Wuse-after-free]
  188 |     free((void *) indices);
      |     ^~~~~~~~~~~~~~~~~~~~~~
compressMG1.c:179:3: note: call to ‘free’ here
  179 |   free((void *) indices);
      |   ^~~~~~~~~~~~~~~~~~~~~~
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.

1 participant