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.
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.