You probably need a `if (!heap) {` check here.

-[Unknown]