Fix Svace warning related to minizip 49/154249/1
authorKiseok Chang <kiso.chang@samsung.com>
Tue, 10 Oct 2017 02:17:54 +0000 (11:17 +0900)
committerKiseok Chang <kiso.chang@samsung.com>
Tue, 10 Oct 2017 02:18:50 +0000 (11:18 +0900)
Change-Id: Iadc2d99648144eb37588af7d5765fdd389d87c99
Signed-off-by: Kiseok Chang <kiso.chang@samsung.com>
setting-license/src/setting-license-view.c

index c00aaade7a9661e0bf0c490946db793290bf76f5..b528db4d2d4781b88b581a9999938a0d4b1de8ea 100755 (executable)
@@ -158,12 +158,15 @@ static int readZipFile(char *zipFile, char *fileInZip)
                // second argument of unzLocateFile: 1 = case sensitive, 0 = case-insensitive
                SETTING_TRACE("File %s not found in %s", fileInZip, zipFile);
                unzCloseCurrentFile(uf);  // close the zipfile
+               unzClose(uf);
                return -1;
        } // file inside zip found
 
-       if (unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0)) {
+       err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
+       if (err != UNZ_OK) {
                SETTING_TRACE("Error %d with zipfile %s in unzGetCurrentFileInfo.", err, zipFile);
                unzCloseCurrentFile(uf);  // close the zipfile
+               unzClose(uf);
                return -1;
        } // obtained the necessary details about file inside zip
 
@@ -171,6 +174,7 @@ static int readZipFile(char *zipFile, char *fileInZip)
        if (buf == NULL) {
                SETTING_TRACE("Error allocating memory for read buffer");
                unzCloseCurrentFile(uf);  // close the zipfile
+               unzClose(uf);
                return -1;
        } // buffer ready
 
@@ -179,6 +183,7 @@ static int readZipFile(char *zipFile, char *fileInZip)
                SETTING_TRACE("Error %d with zipfile %s in unzOpenCurrentFilePassword.", err, zipFile);
                free(buf);
                unzCloseCurrentFile(uf);  // close the zipfile
+               unzClose(uf);
                return -1;
        } // file inside the zip is open
 
@@ -189,6 +194,7 @@ static int readZipFile(char *zipFile, char *fileInZip)
                SETTING_TRACE("Error to write tempfile :  %s", tempfilename);
                free(buf);
                unzCloseCurrentFile(uf);  // close the zipfile
+               unzClose(uf);
                return -1;
        } // open temp file
 
@@ -202,15 +208,12 @@ static int readZipFile(char *zipFile, char *fileInZip)
                }
                // copy the buffer to a string
                if (err > 0) {
-                       //for (int i = 0; i < (int) err; i++)
-                               //sout.push_back( *(((char*)buf)+i) );
                        fwrite(buf, sizeof(char), err, tempfile_fp);
                }
        } while (err > 0);
 
-       err = unzCloseCurrentFile(uf);  // close the zipfile
-       if (err != UNZ_OK)
-               SETTING_TRACE("Error %d with zipfile %s in unzCloseCurrentFile", err, zipFile);
+       unzCloseCurrentFile(uf);  // close the zipfile
+       unzClose(uf);
 
        free(buf); // free up buffer memory