Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

ANDROID.UF.BITMAP

UF (Use Freed) issues are reported when there is an attempt to use resources after they were released. The ANDROID.UF.BITMAP warning indicates an attempt to get pixel(s) from a Bitmap or set pixel(s) into a Bitmap after it was recycled.

Example 1

19     public void addWatermark(final byte[] data) {
20         final Bitmap bmp = loadBitmap(data);
21         if (bmp != null) {
22             final int width = bmp.getWidth();
23             for (int i = 0; i < width; i++) {
24                 bmp.setPixel(i, i, Color.argb(255, 0, 0, 0));
25             }
26         }
27     }
28 
29     private Bitmap loadBitmap(byte[] data) {
30         final Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
31         if (bmp == null) {
32             Log.d(TAG, "Was not able to decode an image");
33         }
34 
35         final int width = bmp.getWidth();
36         final int height = bmp.getHeight();
37         if (width <= 3 || height <= 3 ) {
38             bmp.recycle();
39         }
40         return bmp;
41     }

ANDROID.UF.BITMAP is reported for the snippet on line 24 since method 'loadBitmap()' recycles the bitmap if one of its dimensions is less than '3' (line 38).

Extension

This checker can be extended through the Klocwork knowledge base. See Tuning Java analysis for more information.