File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ static PyObject* p11_error() {
1717 NULL );
1818 PyObject * errmsg = PyUnicode_FromWideChar (msgbuffer , l );
1919 LocalFree (msgbuffer );
20+ if (errmsg == NULL ) {
21+ Py_RETURN_NONE ;
22+ }
2023 return errmsg ;
2124 } else {
2225 Py_RETURN_NONE ;
@@ -61,7 +64,9 @@ static PyObject* p11_error() {
6164 }
6265 int len = strlen (error );
6366 PyObject * result = PyUnicode_DecodeUTF8 (error , len , NULL );
64- PyMem_Free (error );
67+ if (result == NULL ) {
68+ Py_RETURN_NONE ;
69+ }
6570 return result ;
6671}
6772
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ def test_double_initialise(self):
1414 self .assertIsNotNone (pkcs11 .lib (LIB ))
1515 self .assertIsNotNone (pkcs11 .lib (LIB ))
1616
17+ def test_nonexistent_lib (self ):
18+ with self .assertRaises (RuntimeError ):
19+ pkcs11 .lib ("thislibdoesntexist.so" )
20+
1721 def test_double_initialise_different_libs (self ):
1822 self .assertIsNotNone (pkcs11 .lib (LIB ))
1923 with self .assertRaises (pkcs11 .AlreadyInitialized ):
You can’t perform that action at this time.
0 commit comments