Skip to content

Instantly share code, notes, and snippets.

@ss23
Last active August 6, 2023 16:28
Show Gist options
  • Save ss23/f9bc215012d1c2f31002ad5d93378d9d to your computer and use it in GitHub Desktop.
Save ss23/f9bc215012d1c2f31002ad5d93378d9d to your computer and use it in GitHub Desktop.
void *oldbuf = view->buf;
view->buf = realloc(oldbuf, 1000);
if (view->buf == NULL) {
if (oldbuf != NULL)
free(oldbuf);
@ss23
Copy link
Author

ss23 commented Aug 6, 2023

../src/gui/image_display.c: In function 'allocate_full_surface':
../src/gui/image_display.c:92:25: error: pointer 'oldbuf' may be used after 'realloc' [-Werror=use-after-free]
92 | free(oldbuf);
| ^~~~~~~~~~~~
../src/gui/image_display.c:89:29: note: call to 'realloc' here
89 | view->buf = realloc(oldbuf, stride * gfit.ry * sizeof(guchar));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment