-
Notifications
You must be signed in to change notification settings - Fork 41
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
Strncpy #809
Strncpy #809
Conversation
strncpy_or_truncate(chr->cutscene_text[i], trn.locales[0]->end_texts[0][i], | ||
strlen(trn.locales[0]->end_texts[0][i])); |
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.
This is equivalent to calling strcpy(dst, src)
, and every bit as dangerous.
Do not strncpy(dst, src, strlen(src))
.
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, also the omf_calloc is just on the previous line, but let's try strdup then.
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.
omf_strdup, i think we have
@@ -62,8 +62,6 @@ int sd_vga_image_decode(sd_rgba_image *dst, const sd_vga_image *src, const vga_p | |||
} | |||
|
|||
int sd_vga_image_from_png(sd_vga_image *img, const char *filename) { |
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.
Is there a benefit to these sd_vga_image_from_png changes?
Also: i believe this is now leaking memory, as info_ptr is not consistently passed to png_destroy_read_struct for freeing.
@@ -181,7 +182,7 @@ int sd_chr_load(sd_chr_file *chr, const char *filename) { | |||
for(int m = 0; m < 10; m++) { | |||
if(trn_loaded && trn.enemies[i]->quotes[m]) { | |||
chr->enemies[i]->pilot.quotes[m] = omf_calloc(1, strlen(trn.enemies[i]->quotes[m]) + 1); | |||
strncpy(chr->enemies[i]->pilot.quotes[m], trn.enemies[i]->quotes[m], strlen(trn.enemies[i]->quotes[m])); | |||
strncpy_or_truncate(chr->enemies[i]->pilot.quotes[m], trn.enemies[i]->quotes[m], strlen(trn.enemies[i]->quotes[m])); |
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.
Ditto.
This is equivalent to calling strcpy(dst, src), and every bit as dangerous.
Do not strncpy(dst, src, strlen(src)).
didn't notice this was a draft before reviewing it, oops? |
No description provided.