Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20164/win32/src
Modified Files:
PySECURITY_DESCRIPTOR.cpp
Log Message:
Add allocation checks to _MakeSelfRelativeSD
Index: PySECURITY_DESCRIPTOR.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** PySECURITY_DESCRIPTOR.cpp 4 Dec 2006 03:51:52 -0000 1.17
--- PySECURITY_DESCRIPTOR.cpp 4 Dec 2006 04:56:08 -0000 1.18
***************
*** 157,161 ****
*ppsd_relative = malloc(buflen);
! if (MakeSelfRelativeSD(psd_absolute,*ppsd_relative,&buflen))
return TRUE;
free(*ppsd_relative);
--- 157,165 ----
*ppsd_relative = malloc(buflen);
! if (*ppsd_relative==NULL){
! PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", buflen);
! return FALSE;
! }
! if (MakeSelfRelativeSD(psd_absolute,*ppsd_relative,&buflen))
return TRUE;
free(*ppsd_relative);
***************
*** 167,173 ****
--- 171,182 ----
*ppsd_relative = malloc(buflen);
+ if (*ppsd_relative==NULL){
+ PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", buflen);
+ return FALSE;
+ }
if (MakeSelfRelativeSD(psd_absolute,*ppsd_relative,&buflen))
return TRUE;
free(*ppsd_relative);
+ *ppsd_relative=NULL;
PyWin_SetAPIError("MakeSelfRelativeSD");
return FALSE;
***************
*** 254,258 ****
error_exit:
*ppsd_absolute=NULL;
! // *Don't* use FreeAbsoluteSD aince function may exit without the sd having been constructed yet
if (psd_absolute!=NULL)
free(psd_absolute);
--- 263,267 ----
error_exit:
*ppsd_absolute=NULL;
! // *Don't* use FreeAbsoluteSD since function may exit without the sd having been constructed yet
if (psd_absolute!=NULL)
free(psd_absolute);
|