Fix memory leaks 39/111939/1
authorSangyoon Jang <s89.jang@samsung.com>
Wed, 25 Jan 2017 05:07:34 +0000 (14:07 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Wed, 25 Jan 2017 05:07:44 +0000 (14:07 +0900)
Change-Id: I2f51cca965293143557b590fb40b29f523e0152c
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
parser/src/pkgmgr_parser.c

index 52c8328..a71f6b1 100644 (file)
@@ -189,24 +189,30 @@ API int pkgmgr_parser_check_manifest_validation(const char *manifest)
        xschema = xmlSchemaParse(ctx);
        if (xschema == NULL) {
                _LOGE("xmlSchemaParse() Failed\n");
+               xmlSchemaFreeParserCtxt(ctx);
                return PMINFO_R_ERROR;
        }
        vctx = xmlSchemaNewValidCtxt(xschema);
        if (vctx == NULL) {
                _LOGE("xmlSchemaNewValidCtxt() Failed\n");
+               xmlSchemaFree(xschema);
+               xmlSchemaFreeParserCtxt(ctx);
                return PMINFO_R_ERROR;
        }
        xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
        ret = xmlSchemaValidateFile(vctx, manifest, 0);
        if (ret == -1) {
                _LOGE("xmlSchemaValidateFile() failed\n");
-               return PMINFO_R_ERROR;
+               ret = PMINFO_R_ERROR;
        } else if (ret == 0) {
                _LOGD("Manifest is Valid\n");
-               return PMINFO_R_OK;
+               ret = PMINFO_R_OK;
        } else {
                _LOGE("Manifest Validation Failed with error code %d\n", ret);
-               return PMINFO_R_ERROR;
+               ret = PMINFO_R_ERROR;
        }
-       return PMINFO_R_OK;
+       xmlSchemaFreeValidCtxt(vctx);
+       xmlSchemaFree(xschema);
+       xmlSchemaFreeParserCtxt(ctx);
+       return ret;
 }