@@ -131,13 +131,15 @@ weakref_repr(PyWeakReference *self)
131131{
132132 char buffer [256 ];
133133 if (PyWeakref_GET_OBJECT (self ) == Py_None ) {
134- sprintf (buffer , "<weakref at %lx; dead>" ,
135- (long )(self ));
134+ PyOS_snprintf (buffer , sizeof ( buffer ) , "<weakref at %lx; dead>" ,
135+ (long )(self ));
136136 }
137137 else {
138- sprintf (buffer , "<weakref at %#lx; to '%.50s' at %#lx>" ,
139- (long )(self ), PyWeakref_GET_OBJECT (self )-> ob_type -> tp_name ,
140- (long )(PyWeakref_GET_OBJECT (self )));
138+ PyOS_snprintf (buffer , sizeof (buffer ),
139+ "<weakref at %#lx; to '%.50s' at %#lx>" ,
140+ (long )(self ),
141+ PyWeakref_GET_OBJECT (self )-> ob_type -> tp_name ,
142+ (long )(PyWeakref_GET_OBJECT (self )));
141143 }
142144 return PyString_FromString (buffer );
143145}
@@ -265,9 +267,10 @@ static PyObject *
265267proxy_repr (PyWeakReference * proxy )
266268{
267269 char buf [160 ];
268- sprintf (buf , "<weakref at %p to %.100s at %p>" , proxy ,
269- PyWeakref_GET_OBJECT (proxy )-> ob_type -> tp_name ,
270- PyWeakref_GET_OBJECT (proxy ));
270+ PyOS_snprintf (buf , sizeof (buf ),
271+ "<weakref at %p to %.100s at %p>" , proxy ,
272+ PyWeakref_GET_OBJECT (proxy )-> ob_type -> tp_name ,
273+ PyWeakref_GET_OBJECT (proxy ));
271274 return PyString_FromString (buf );
272275}
273276
0 commit comments