Skip to content

Commit bfed1d8

Browse files
committed
memcpy instead of snprintf
1 parent 981ba66 commit bfed1d8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/_libs/src/ujson/lib/ultrajsondec.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1179,12 +1179,12 @@ JSOBJ JSON_DecodeObject(JSONObjectDecoder *dec, const char *buffer,
11791179
}
11801180

11811181
if (strcmp(locale, "C")) {
1182-
int len = strlen(locale) + 1;
1182+
size_t len = strlen(locale) + 1;
11831183
char *origLocale = malloc(len);
11841184
if (origLocale == NULL) {
11851185
return SetError(&ds, -1, "Could not reserve memory block");
11861186
}
1187-
snprintf(origLocale, len, "%s", locale);
1187+
memcpy(origLocale, locale, len);
11881188
setlocale(LC_NUMERIC, "C");
11891189
ret = decode_any(&ds);
11901190
setlocale(LC_NUMERIC, origLocale);

pandas/_libs/src/ujson/lib/ultrajsonenc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1182,13 +1182,13 @@ char *JSON_EncodeObject(JSOBJ obj, JSONObjectEncoder *enc, char *_buffer,
11821182
}
11831183

11841184
if (strcmp(locale, "C")) {
1185-
int len = strlen(locale) + 1;
1185+
size_t len = strlen(locale) + 1;
11861186
char *origLocale = malloc(len);
11871187
if (origLocale == NULL) {
11881188
SetError(NULL, enc, "Could not reserve memory block");
11891189
return NULL;
11901190
}
1191-
snprintf(origLocale, len, "%s", locale);
1191+
memcpy(origLocale, locale, len);
11921192
setlocale(LC_NUMERIC, "C");
11931193
encode(obj, enc, NULL, 0);
11941194
setlocale(LC_NUMERIC, origLocale);

0 commit comments

Comments
 (0)