#fixed code
                                private static String getCharsetFromBOM(final byte[] byteData) {
        try (BOMInputStream bomIn = new BOMInputStream(
                new ByteArrayInputStream(byteData))) {
            ByteOrderMark bom = bomIn.getBOM();
            if (bom != null) {
                return bom.getCharsetName();
            }
        } catch (IOException e) {
            return null;
        }
        return null;
    }
#vulnerable code 
                                private static String getCharsetFromBOM(final byte[] byteData) {
        BOMInputStream bomIn = new BOMInputStream(new ByteArrayInputStream(
                byteData));
        try {
            ByteOrderMark bom = bomIn.getBOM();
            if (bom != null) {
                return bom.getCharsetName();
            }
        } catch (IOException e) {
            return null;
        }
        return null;
    } 
                            #location 5 
                            #vulnerability type RESOURCE_LEAK