util: add proper check for null pointer in wmsetbg (Coverity #50198)