apple / ccs-pykerberos

Python Kerberos library used by CalendarServer
https://www.calendarserver.org
Apache License 2.0
117 stars 65 forks source link

Check result of memory allocation #44

Closed macosforgebot closed 9 years ago

macosforgebot commented 9 years ago

glen@… originally submitted this as ticket:914


To give PyKerberos a fighting chance under low memory conditions we should check the value returned by malloc (and by functions that use malloc on our behalf), before attempting to access the memory and causing a possible segfault. Attached is a patch that does this - in the event malloc returns NULL it will generally cause a Python MemoryError to be raise by calling PyErr_NoMemory(), although the exact handling depends on the context.

macosforgebot commented 9 years ago

glen@… originally submitted this as _attachment:handle_malloc_failure.diff:⁠ticket:914_

macosforgebot commented 9 years ago

@cyrusdaboo originally submitted this as comment:1:⁠ticket:914


Fixed in r15140. Thanks for the patch.