Skip to content

Commit d72bc27

Browse files
committed
objint: Fix corner case in buffer access.
1 parent b56a53d commit d72bc27

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

py/objint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ STATIC uint int_as_str_size_formatted(uint base, const char *prefix, char comma)
127127
return num_digits + num_commas + prefix_len + 2; // +1 for sign, +1 for null byte
128128
}
129129

130-
// This routine expects you to pass in a buffer and size (in *buf and buf_size).
130+
// This routine expects you to pass in a buffer and size (in *buf and *buf_size).
131131
// If, for some reason, this buffer is too small, then it will allocate a
132132
// buffer and return the allocated buffer and size in *buf and *buf_size. It
133133
// is the callers responsibility to free this allocated buffer.
@@ -154,7 +154,7 @@ char *mp_obj_int_formatted(char **buf, int *buf_size, int *fmt_size, mp_const_ob
154154
#endif
155155
} else {
156156
// Not an int.
157-
buf[0] = '\0';
157+
**buf = '\0';
158158
*fmt_size = 0;
159159
return *buf;
160160
}

0 commit comments

Comments
 (0)