From 9c1c8d9645fa0dd9033eb4afc7025c66bcf10ef9 Mon Sep 17 00:00:00 2001
From: Przemyslaw Ciezkowski
Date: Mon, 5 Nov 2012 16:55:23 +0100
Subject: [PATCH] Fix resource leak
[Issue#] LINUXNGWAP-506
[Bug] FILE resource resFp may not be released when encFp is not
properly initialized (fopen error, returning from function).
[Cause] N/A
[Solution] Release resFp right after it is used.
[Verification] Install tizen spec manual test case: TC21, check if
widget file "index.html" is encrypted.
Change-Id: I8a8393df17b7d49b297bf42db2c3c44a758ce2be
---
src/jobs/widget_install/task_encrypt_resource.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp
index d133d83..9b0bdb4 100644
--- a/src/jobs/widget_install/task_encrypt_resource.cpp
+++ b/src/jobs/widget_install/task_encrypt_resource.cpp
@@ -162,6 +162,7 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName)
memset(outEncBuf, 0, blockSize);
fread(readBuf, sizeof(unsigned char), fileSize, resFp);
+ fclose(resFp);
m_resEnc->EncryptChunk(readBuf, outEncBuf, fileSize);
@@ -171,8 +172,6 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName)
return;
}
fwrite(outEncBuf, sizeof(unsigned char), blockSize, encFp);
-
- fclose(resFp);
fclose(encFp);
LogDebug("Success to encrypt file");
--
2.7.4