Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix bug caused by missing return value check#1769

Open
MicroMilo wants to merge 3 commits intocoturn:masterfrom
MicroMilo:master
Open

Fix bug caused by missing return value check#1769
MicroMilo wants to merge 3 commits intocoturn:masterfrom
MicroMilo:master

Conversation

@MicroMilo
Copy link

Fix #1766

@MicroMilo MicroMilo changed the title Fix bug caused by clmessage_length Fix bug caused by missing return value check Nov 15, 2025
@MicroMilo
Copy link
Author

There are also some similar bugs need to fix.
I'll fix it as soon as I can.

@eakraly
Copy link
Collaborator

eakraly commented Nov 23, 2025

Hi @MicroMilo
Thank you for the PR

While some of the changes make sense (clmessage length and division by 0) - the rest of return value checks are actually bad IMHO
There is no backup plan or recovery from failure to allocate memory and it is good that the app crashes
If malloc/calloc/realloc fail - there is absolutely no point to try and continue running. Moreover, it is harmful as it hides the real issue (if the app actually runs for some time after failure to allocate memory)
In some place, the fix includes logging the issue - which again needs memory allocated. In this case, best case scenario, the crash will show that memory allocation failed in logging - which is not true issue.

This is a generic issue with automatic scanners that warn about return value validation. In case of memory allocation - those do not have value.

To sum it up: I recommend against memory allocation validation changes - I'll review the rest after that.

Thanks again!

@MicroMilo
Copy link
Author

Thanks, @eakraly.
Thank you for your response. I think I know what you think about memory management.
I put forward this PR out of the discussion in #1762.

Leaving memory management aside, I still have some issues regarding null Pointers. Do you want me to request a PR?
for example: #1763, #1765

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.

Potential NULL Pointer Dereference or Divede Zero found in client_read

2 participants