Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
fix: buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Antares0982 committed May 11, 2024
1 parent ff13f65 commit 46b5f4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pycJSON_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static bool print_number(PyObject *item, printbuffer *const output_buffer) {

int length = 0;
size_t i = 0;
unsigned char number_buffer[32] = {0}; /* temporary buffer to print the number into */
unsigned char number_buffer[64] = {0}; /* temporary buffer to print the number into */
unsigned char decimal_point = get_decimal_point();

if (output_buffer == NULL) {
Expand Down Expand Up @@ -148,7 +148,7 @@ static bool print_number(PyObject *item, printbuffer *const output_buffer) {
if (dconv_d2s_ptr == NULL) {
dconv_d2s_init(&dconv_d2s_ptr, NO_FLAGS, "Infinity", "NaN", 'e', -324, 308, 0, 0);
}
dconv_d2s(dconv_d2s_ptr, d, (char *) number_buffer, 32, &length);
dconv_d2s(dconv_d2s_ptr, d, (char *) number_buffer, sizeof(number_buffer), &length);
// /* Check whether the original double can be recovered */
// if ((sscanf((char *) number_buffer, "%lg", &test) != 1) || !compare_double((double) test, d)) {
// /* If not, print with 17 decimal places of precision */
Expand Down

0 comments on commit 46b5f4e

Please sign in to comment.