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

UF.ZIP

UF (Use Freed) issues are reported when there is an attempt to use resources after they were released. The UF.ZIP warning indicates an attempt to use a ZipFile after it was closed.

Example 1

18     public static final void copy(InputStream in, OutputStream out) throws IOException {
19         byte[] buffer = new byte[1024];
20         int len;
21 
22         while ((len = in.read(buffer)) >= 0) {
23             out.write(buffer, 0, len);
24         }
25 
26         in.close();
27         out.close();
28     }
29 
30     public final void unzip(final ZipFile zipFile) {
31         Enumeration entries;
32         entries = zipFile.entries();
33 
34         try {
35             while (entries.hasMoreElements()) {
36                 ZipEntry entry = (ZipEntry) entries.nextElement();
37 
38                 if (entry.isDirectory()) {
39                     final File dir = new File(entry.getName());
40                     dir.mkdir();
41                 } else {
42                     try {
43                         copy(zipFile.getInputStream(entry), new FileOutputStream(entry.getName()));
44                     } catch (IOException e) {
45                         zipFile.close();
46                     }
47                 }
48             }
49 
50             zipFile.close();
51         } catch (IOException e) {
52             // do nothing
53         }
54     }

UF.ZIP is reported for the snippet on line 43: 'zipFile' is closed on line 45 in case of an IOException, but there will be an attempt to access 'zipFile' on the next iteration of the cycle.