File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,9 +36,10 @@ static PyObject * _crypt_gensalt(PyObject *self, PyObject *args)
3636 errno = 0 ;
3737 int nrbytes ;
3838 unsigned long count ;
39- char * _hash = NULL ;
39+ char * setting = NULL ;
4040 const char * prefix , * rbytes ;
4141 Py_ssize_t * dumb_sz_1 , * dumb_sz_2 ;
42+ PyObject * output = NULL ;
4243
4344 if (PyTuple_Size (args ) != 4 )
4445 {
@@ -51,14 +52,21 @@ static PyObject * _crypt_gensalt(PyObject *self, PyObject *args)
5152 PyErr_SetString (PyExc_TypeError , "Arguments parsing" );
5253 return NULL ;
5354 }
54-
55- if (( _hash = crypt_gensalt_ra ( prefix , count , rbytes , nrbytes )) == NULL )
55+ setting = crypt_gensalt_ra ( prefix , count , rbytes , nrbytes );
56+ if (setting == NULL )
5657 {
58+ if (errno == ENOMEM )
59+ {
60+ PyErr_SetString (PyExc_MemoryError , strerror (errno ));
61+ return NULL ;
62+ }
5763 PyErr_SetString (PyExc_RuntimeError , strerror (errno ));
5864 return NULL ;
5965 }
66+ output = Py_BuildValue ("z" , setting );
67+ free (setting );
6068
61- return Py_BuildValue ( "z" , _hash ) ;
69+ return output ;
6270}
6371
6472static PyObject * _crypt (PyObject * self , PyObject * args )
You can’t perform that action at this time.
0 commit comments