Skip to content
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

chore: remove usage of sprintf #1453

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/carp_pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,13 @@ Array Pattern_match_MINUS_all_MINUS_groups(Pattern *p, String *s) {
String Pattern_internal_add_char(String a, Char b) {
if (!a) {
String buffer = CARP_MALLOC(2);
sprintf(buffer, "%c", b);
snprintf(buffer, 1, "%c", b);
return buffer;
}

int len = strlen(a) + 2;
String buffer = CARP_MALLOC(len);
sprintf(buffer, "%s%c", a, b);
snprintf(buffer, len-1, "%s%c", a, b);
CARP_FREE(a);
return buffer;
}
Expand Down Expand Up @@ -645,7 +645,7 @@ String Pattern_substitute(Pattern *p, String *s, String *t, int ns) {

int l = strlen(res) + strlen(str) + 1;
String buffer = CARP_MALLOC(l);
sprintf(buffer, "%s%s", res, str);
snprintf(buffer, l-1, "%s%s", res, str);
CARP_FREE(res);
return buffer;
}
Expand All @@ -671,7 +671,7 @@ String Pattern_str(Pattern *p) {
String Pattern_prn(Pattern *p) {
int n = strlen(*p) + 4;
String buffer = CARP_MALLOC(n);
sprintf(buffer, "#\"%s\"", *p);
snprintf(buffer, n-1, "#\"%s\"", *p);
return buffer;
}

Expand Down