Memory allocation issue detected by coverity CID 25812