Kaydet (Commit) 736f265c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

cid#1326523,1326524: Resource leak on an exceptional path

Change-Id: I34016e7124ff33700bb33801145f478ed34e9262
üst 09fc095d
......@@ -60,18 +60,28 @@ final class WinRegKey {
if ( is != null ) {
// generate a temporary name for lib file and write to temp
// location
BufferedInputStream istream = new BufferedInputStream( is );
File libfile = File.createTempFile( "unowinreg", ".dll" );
libfile.deleteOnExit(); // ensure deletion
BufferedOutputStream ostream = new BufferedOutputStream(
new FileOutputStream( libfile ) );
int bsize = 2048; int n = 0;
byte[] buffer = new byte[bsize];
while ( ( n = istream.read( buffer, 0, bsize ) ) != -1 ) {
ostream.write( buffer, 0, n );
File libfile;
BufferedInputStream istream = null;
BufferedOutputStream ostream = null;
try {
istream = new BufferedInputStream( is );
libfile = File.createTempFile( "unowinreg", ".dll" );
libfile.deleteOnExit(); // ensure deletion
ostream = new BufferedOutputStream(
new FileOutputStream( libfile ) );
int bsize = 2048; int n = 0;
byte[] buffer = new byte[bsize];
while ( ( n = istream.read( buffer, 0, bsize ) ) != -1 ) {
ostream.write( buffer, 0, n );
}
} finally {
if (istream != null) {
istream.close();
}
if (ostream != null) {
ostream.close();
}
}
istream.close();
ostream.close();
// load library
System.load( libfile.getPath() );
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment