summaryrefslogtreecommitdiffstats
path: root/Objects/complexobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r--Objects/complexobject.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index c6e3343..aa8fc81 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -274,16 +274,16 @@ complex_to_buf(char *buf, int bufsz, PyComplexObject *v, int precision)
{
char format[32];
if (v->cval.real == 0.) {
- PyOS_snprintf(format, 32, "%%.%ig", precision);
- PyOS_ascii_formatd(buf, bufsz, format, v->cval.imag);
- strncat(buf, "j", bufsz);
+ PyOS_snprintf(format, sizeof(format), "%%.%ig", precision);
+ PyOS_ascii_formatd(buf, bufsz - 1, format, v->cval.imag);
+ strncat(buf, "j", 1);
} else {
char re[64], im[64];
/* Format imaginary part with sign, real part without */
- PyOS_snprintf(format, 32, "%%.%ig", precision);
- PyOS_ascii_formatd(re, 64, format, v->cval.real);
- PyOS_snprintf(format, 32, "%%+.%ig", precision);
- PyOS_ascii_formatd(im, 64, format, v->cval.imag);
+ PyOS_snprintf(format, sizeof(format), "%%.%ig", precision);
+ PyOS_ascii_formatd(re, sizeof(re), format, v->cval.real);
+ PyOS_snprintf(format, sizeof(format), "%%+.%ig", precision);
+ PyOS_ascii_formatd(im, sizeof(im), format, v->cval.imag);
PyOS_snprintf(buf, bufsz, "(%s%sj)", re, im);
}
}