PDF: fix potential memory leak