@@ -3636,7 +3636,7 @@ dec_format(PyObject *dec, PyObject *args)
36363636static PyObject *
36373637dec_as_long (PyObject * dec , PyObject * context , int round )
36383638{
3639- digit * ob_digit ;
3639+ void * digits ;
36403640 size_t n ;
36413641 mpd_t * x ;
36423642 mpd_context_t workctx ;
@@ -3676,20 +3676,20 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
36763676 }
36773677
36783678 n = (mpd_sizeinbase (x , 2 ) + PyLong_SHIFT - 1 )/PyLong_SHIFT ;
3679- PyLongWriter * writer = PyLongWriter_Create (mpd_isnegative (x ), n ,
3680- (void * * )& ob_digit );
3681- /* mpd_sizeinbase can overestimate size by 1 digit, set it to zero. */
3682- ob_digit [n - 1 ] = 0 ;
3679+ PyLongWriter * writer = PyLongWriter_Create (mpd_isnegative (x ), n , & digits );
36833680 if (writer == NULL ) {
36843681 mpd_del (x );
36853682 return NULL ;
36863683 }
36873684
36883685 status = 0 ;
3686+ /* mpd_sizeinbase can overestimate size by 1 digit, set it to zero. */
36893687#if PYLONG_BITS_IN_DIGIT == 30
3690- n = mpd_qexport_u32 (& ob_digit , n , PyLong_BASE , x , & status );
3688+ memset (digits + sizeof (uint32_t )* (n - 1 ), 0 , sizeof (uint32_t ));
3689+ n = mpd_qexport_u32 ((uint32_t * * )& digits , n , PyLong_BASE , x , & status );
36913690#elif PYLONG_BITS_IN_DIGIT == 15
3692- n = mpd_qexport_u16 (& ob_digit , n , PyLong_BASE , x , & status );
3691+ memset (digits + sizeof (unit16_t )* (n - 1 ), 0 , sizeof (uint16_t ));
3692+ n = mpd_qexport_u16 ((uint16_t * * )& digits , n , PyLong_BASE , x , & status );
36933693#else
36943694 #error "PYLONG_BITS_IN_DIGIT should be 15 or 30"
36953695#endif
0 commit comments