fixed two potential memory leaks reported by the static analzyer