summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeit Heller <veit@veitheller.de>2023-01-31 20:47:15 +0100
committerGitHub <noreply@github.com>2023-01-31 20:47:15 +0100
commitca5774b1aeeab2bc4d6fa901b5a55682ebc2d539 (patch)
tree6db1a9d93a65f4539111743968acbcea28c1c3b2
parent7ab466edebd5fd5f3958330ac353477937a11c85 (diff)
chore: remove usage of sprintf (#1453)
-rw-r--r--core/carp_pattern.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/carp_pattern.h b/core/carp_pattern.h
index e86e8d0f..c855320d 100644
--- a/core/carp_pattern.h
+++ b/core/carp_pattern.h
@@ -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;
}
@@ -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;
}
@@ -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;
}