Skip to content

Conversation

@weiso131
Copy link
Contributor

When an error occurs, the goto error handling path attempts to free and return variables that might not have been initialized yet. This may lead to undefined behavior or crashes.

This patch ensures variables are initialized properly before use in the error path, and avoids double-free or invalid free issues.

Observed with valgrind:
==33961== Conditional jump or move depends on uninitialised value(s)
==33961== at 0x4849845: free
(in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==33961== by 0x1093A7: main
(in /home/weiso131/linux_2025/ksort/user)

When an error occurs, the goto error handling path attempts to free
and return variables that might not have been initialized yet.
This may lead to undefined behavior or crashes.

This patch ensures variables are initialized properly before use
in the error path, and avoids double-free or invalid free issues.

Observed with valgrind:
==33961== Conditional jump or move depends on uninitialised value(s)
==33961==    at 0x4849845: free
(in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==33961==    by 0x1093A7: main
(in /home/weiso131/linux_2025/ksort/user)
@jserv jserv merged commit c5b2eab into sysprog21:master Mar 23, 2025
@jserv
Copy link
Contributor

jserv commented Mar 23, 2025

Thank @weiso131 for contributing!

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.

2 participants