-
Notifications
You must be signed in to change notification settings - Fork 158
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
Fix multiple instances of undefined behaviour and crashes when using ubsan #677
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,9 @@ HL_PRIM vbyte *hl_copy_bytes( const vbyte *ptr, int size ) { | |
} | ||
|
||
HL_PRIM void hl_bytes_blit( char *dst, int dpos, char *src, int spos, int len ) { | ||
memmove(dst + dpos,src+spos,len); | ||
if(dst && src) { | ||
memmove(dst + dpos,src + spos,len); | ||
} | ||
} | ||
|
||
HL_PRIM int hl_bytes_compare( vbyte *a, int apos, vbyte *b, int bpos, int len ) { | ||
|
@@ -143,7 +145,9 @@ HL_PRIM int hl_bytes_rfind( vbyte *where, int len, vbyte *which, int wlen ) { | |
} | ||
|
||
HL_PRIM void hl_bytes_fill( vbyte *bytes, int pos, int len, int value ) { | ||
memset(bytes+pos,value,len); | ||
if(bytes) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this will now fail silently? If this check is performed, might as well emit a warning or something? Additionally, I guess this situation ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That happened when I was testing the changes with some openfl templates. It seems that somewhere it passes NULL to Edit: About the warning, where should it be emitted? to stderr? |
||
memset(bytes+pos,value,len); | ||
} | ||
} | ||
|
||
|
||
|
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.
I wonder: is this assumption ever violated? Can we use an
assume
intrinsic or similar?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.
Well, when hashlink starts gc_roots == NULL.
So, we can add that check or initialize it before calling hl_add_root() somewhere else.