st/mesa: add some null pointer checking to better handle out of memory