#fixed code
                                public void drawTitle(String title, PDFont font, int fontSize, TextType textType) throws IOException {
        PDPageContentStream articleTitle = createPdPageContentStream();

        articleTitle.beginText();
        articleTitle.setFont(font, fontSize);
        articleTitle.moveTextPositionByAmount(getMargin(), yStart);
        articleTitle.setNonStrokingColor(Color.black);
        articleTitle.drawString(title);
        articleTitle.endText();

        if (textType != null) {
            switch (textType) {
                case HIGHLIGHT:
                    throw new NotImplementedException();
                case SQUIGGLY:
                    throw new NotImplementedException();
                case STRIKEOUT:
                    throw new NotImplementedException();
                case UNDERLINE:
                    float y = (float) (yStart - 1.5);
                    float titleWidth = font.getStringWidth(title) / 1000 * fontSize;
                    articleTitle.drawLine(getMargin(), y, getMargin() + titleWidth, y);
                    break;
                default:
                    break;
            }
        }
        articleTitle.close();

        yStart = (float) (yStart - (fontSize / 1.5));

    }
#vulnerable code 
                                public void drawTitle(String title, PDFont font, int fontSize, TextType textType) throws IOException {
        PDPageContentStream articleTitle = new PDPageContentStream(this.document, this.currentPage, true, true);

        articleTitle.beginText();
        articleTitle.setFont(font, fontSize);
        articleTitle.moveTextPositionByAmount(getMargin(), yStart);
        articleTitle.setNonStrokingColor(Color.black);
        articleTitle.drawString(title);
        articleTitle.endText();

        if (textType != null) {
            switch (textType) {
                case HIGHLIGHT:
                    throw new NotImplementedException();
                case SQUIGGLY:
                    throw new NotImplementedException();
                case STRIKEOUT:
                    throw new NotImplementedException();
                case UNDERLINE:
                    float y = (float) (yStart - 1.5);
                    float titleWidth = font.getStringWidth(title) / 1000 * fontSize;
                    articleTitle.drawLine(getMargin(), y, getMargin() + titleWidth, y);
                    break;
                default:
                    break;
            }
        }
        articleTitle.close();

        yStart = (float) (yStart - (fontSize / 1.5));

    } 
                            #location 14 
                            #vulnerability type RESOURCE_LEAK