If there is no memory left on the heap malloc will return NULL.
Is the behaviour on stack overflow defined in C?
Wikipedia suggests it's likely to cause a segfault, at least in the case of infinite recursion, but could something else happen?
Also in many managed environments, the runtime does not allow you to create arrays on the stack. Does that mean we should avoid it in native code too to guard against stack overflow, at least when the size of the array is determined at run time?