Really makes me appreciate using language with exceptions and not that crazy "manually check if error handling is required - and do it everywhere". The fix adds:
if (ZEND_HAS_OOM()) { goto oom_nodeset; }