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

Bugfix: use after free #117

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

Conversation

divyekapoor
Copy link

This was detected by cc:

cc main.c fiche.c -pthread -O2 -Wall -Wextra -Wpedantic -Wstrict-overflow -fno-strict-aliasing -std=gnu11 -g -O0 -o fiche fiche.c: In function 'handle_connection':
fiche.c:619:13: warning: pointer 'c' used after 'free' [-Wuse-after-free]
619 | close(c->socket);
| ^~~~~~~~~~~~~~~~
fiche.c:617:13: note: call to 'free' here
617 | free(c);
| ^~~~~~~
paste:~/src/fiche$ ls

$ cc --version
cc (Alpine 13.1.1_git20230708) 13.1.1 20230708
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This was detected by cc:

cc main.c fiche.c -pthread -O2 -Wall -Wextra -Wpedantic -Wstrict-overflow -fno-strict-aliasing -std=gnu11 -g -O0 -o fiche
fiche.c: In function 'handle_connection':
fiche.c:619:13: warning: pointer 'c' used after 'free' [-Wuse-after-free]
  619 |             close(c->socket);
      |             ^~~~~~~~~~~~~~~~
fiche.c:617:13: note: call to 'free' here
  617 |             free(c);
      |             ^~~~~~~
paste:~/src/fiche$ ls


$ cc --version
cc (Alpine 13.1.1_git20230708) 13.1.1 20230708
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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