#vulnerable code 
                                public void testAll5x2Images() {
        int[] combinations = new int[10];
        BufferedImage image = new BufferedImage(5, 2, BufferedImage.TYPE_INT_RGB);
        do {
            for (int x = 0; x < 5; x++) {
                if (combinations[x] == 0) {
                    image.setRGB(x, 0, 0xFFFFFF);
                } else {
                    image.setRGB(x, 0, 0);
                }
            }
            for (int x = 0; x < 5; x++) {
                if (combinations[5 + x] == 0) {
                    image.setRGB(x, 1, 0xFFFFFF);
                } else {
                    image.setRGB(x, 1, 0);   
                }
            }
            
            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_1D);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }
            
            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 0);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }
            
            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 4);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                FileOutputStream fos = new FileOutputStream("/tmp/test.tiff");
                fos.write(compressed);
                fos.close();

                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }

            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 1);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }

            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 5);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }

            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_4);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }
        } while (nextCombination(combinations, 1));
    } 
                            #location 26 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public void testAll5x2Images() {
        int[] combinations = new int[10];
        BufferedImage image = new BufferedImage(5, 2, BufferedImage.TYPE_INT_RGB);
        do {
            for (int x = 0; x < 5; x++) {
                if (combinations[x] == 0) {
                    image.setRGB(x, 0, 0xFFFFFF);
                } else {
                    image.setRGB(x, 0, 0);
                }
            }
            for (int x = 0; x < 5; x++) {
                if (combinations[5 + x] == 0) {
                    image.setRGB(x, 1, 0xFFFFFF);
                } else {
                    image.setRGB(x, 1, 0);   
                }
            }
            
            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_1D);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }
            
            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 0);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }
            
            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 4);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }

            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 1);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }

            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3);
                params.put(TiffConstants.PARAM_KEY_T4_OPTIONS, 5);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }

            try {
                HashMap params = new HashMap();
                params.put(SanselanConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_4);
                byte[] compressed = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_TIFF, params);
                BufferedImage result = Sanselan.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (ImageWriteException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (ImageReadException ex) {
                Debug.debug(ex);
                assertFalse(true);
            } catch (IOException ex) {
                Debug.debug(ex);
                assertFalse(true);
            }
        } while (nextCombination(combinations, 1));
    }