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.MEDIARECORDER

UF (Use Freed) issues are reported when there is an attempt to use resources after they were released. The ANDROID.UF.MEDIARECORDER warning indicates an attempt to use MediaRecorder after it was released.

Example 1

15     public boolean onKeyDown(final int keyCode, final KeyEvent event) {
16         if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
17             MediaRecorder mRecorder = new MediaRecorder();
18 
19             mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
20             mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
21             mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
22 
23             final File file = new File("test.raw");
24             if (file.exists()) {
25                 mRecorder.release();
26             } else {
27                 mRecorder.setOutputFile(file.getPath());
28             }
29 
30             mRecorder.start();
31             mRecorder.release();
32             return true;
33         }
34         return super.onKeyDown(keyCode, event);
35     }

ANDROID.UF.MEDIARECORDER is reported for the snippet on line 30 since there is an attempt to use the 'mRecorder' that is released if the output file exists (line 25).

Extension

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