-
Notifications
You must be signed in to change notification settings - Fork 72
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
Misc. minor fixes #423
Misc. minor fixes #423
Conversation
Looks fine to me, but only from a visual readthrough.
I couldn't find those returns. Did you change this part? I'd suggest not removing returns after fatal errors, since the c compiler doesn't know that |
No, I meant that I removed them from the code @YashasSamaga added in their original fix.
Makes sense, but I removed those returns not only because they would be unreachable, but also to be more in-line with the existing code (in all the other code there are usually no returns after fatal errors). |
Oh I see, then fair enough. |
1e399f0
to
32d5ec0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have the empty string check defined as a macro please? it would be more readable IMO
8b58a37
to
95259ad
Compare
@Zeex Done. |
Thanks, looks good |
* Misc. minor fixes * Fix OOB array access in encode_cell() * Fix memory leaks in plungequalifiedfile() * Remove redundant NULL pointer checks * Fix invalid uses of realloc() * Remove 'do_switch()' * Don't use 'strlen()' to identify empty strings * Other minor fixes * Fix incorrect error message when compression is ineffective * Add macro 'strempty' to identify empty strings
What this PR does / why we need it:
Fixes for various minor bugs that weren't worth making a separate PR for each of them:
Fixed invalid formula for calculating array size (in characters) in function
hier1()
.The cell size in bits was hardcoded as
32
(should besizeof(cell)*8
), which could lead to generation of invalid code for array boundary checks if the Pawn toolkit was configured with 16- or 64-bit cell size.Of course, this bug doesn't affect SA-MP (which is 32-bit), but I think it's still good to have this fix here.
Fixed invalid type cast in
funcstub()
.See refactoring of the codebase #296 (comment).
Fixed OOB array access in
encode_cell()
.This one seems to originate from a commit that I made a year and a half ago (sorry!)
Fixed memory leaks in
plungequalifiedfile()
.Special thanks goes to @YashasSamaga for reporting the bug, as well as providing a fix, though I slightly changed that fix in the following ways:
free(path)
beforeerror(103)
, becausepath
won't be freed otherwise. This is because on fatal errors (1xx)error()
returns (vialongjmp()
) directly to an error buffer set inpc_compile
, so the code after sucherror()
call is never executed.return
s, as they are pretty much useless aftererror(<fatal error code>)
.Removed
NULL
pointer checks before the uses of functionfree()
.free()
does nothing if the pointer isNULL
, so anyNULL
checks before the use offree()
are redundant.Fixed invalid uses of
realloc()
in several places.The old pointer could have got leaked if the function failed to resize the old memory block or allocate a new one.
Simplified the code in function
pushstk()
by replacing a group of calls tomalloc()
/memcpy()
/free()
with onerealloc()
.Removed function
do_switch()
(sc6.c
).Apparently this function was a duplicate of
do_jump()
; it didn't implement any extra checks, so its only difference fromdo_jump()
was in its name.Simplified string emptiness checks.
Using
strlen(<string>)==0
to identify empty strings is inefficient because if the string is not emptystrlen()
traverses through the whole string to get its length.Fixed potential
NULL
pointer dereferences in functionssc_path()
andsetconfig()
.Fixed incorrect error message when compact encoding is ineffective (Incorrect fatal error when compact encoding is ineffective #425).
Other minor adjustments.
Which issue(s) this PR fixes:
Fixes #425
What kind of pull this is:
Additional Documentation: