Fixes #3847 by using puts() and by NUL-terminating szMsg[] #3851
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is one potential way to solve the issues with the
_getdiskfree()
example I brought up in #3847. There's more than one way to solve those problems, so if there's a different way you prefer better, that's fine. I just wanted to suggest one potential way.I changed
printf()
toputs()
, sinceprintf()
was not being used to do any formatting. Sinceputs()
prints a newline after printing the string, I removed the newlines from theg_szXXX[]
constants.I added a check to see if the error message was longer than
g_szLine[]
, and if so, terminate the message with a NUL character, to avoid potentially reading past the end of the buffer.Note: I don't currently have a Windows VM set up (it's on my to-do list) so I wasn't able to test my fixed version of the program. So if you decide to go with my solution, please be sure to test it first, and make sure it compiles and runs. Thanks!