[Bug] Using cJSON_free to free memory allocated by cJSON_Print

issueNo: https://gitee.com/openharmony/developtools_syscap_codec/issues/IAKW57

Signed-off-by: luming <luming29@huawei.com>
This commit is contained in:
luming
2024-08-19 11:42:40 +08:00
parent 670c5856f5
commit 2447b25c21
3 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -26,7 +26,7 @@
#define PCID_MAIN_BYTES 128
#define PCID_MAIN_INTS 32
#define E_EORROR (-1)
#define E_ERROR (-1)
#define E_OK 0
#define E_APIVERSION 1
#define E_SYSCAP 2
@@ -54,7 +54,7 @@ char *DecodeRpcidToStringFormat(const char *inputFile);
* rpcidString, input string format rpcid.
* result, output comparison results.
* retval:
* E_EORROR, compare failed.
* E_ERROR, compare failed.
* E_OK, compare successful and meet the requirements.
* E_APIVERSION, compare successful but api version too low.
* E_SYSCAP, compare successful but missing some syscaps.
+3 -1
View File
@@ -759,7 +759,9 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath)
ret = 0;
FAILED:
SafeFree(jsonBuffer);
if (jsonBuffer != NULL) {
cJSON_free(jsonBuffer)
}
SafeFree(priSyscapStr);
cJSON_Delete(sysCapObj);
cJSON_Delete(rootObj);
+2 -2
View File
@@ -208,7 +208,7 @@ def _check_path_prefix(paths):
def traversal_files(subsystem_path, _files):
for item in os.scandir(subsystem_path):
if is_symlik(item.path):
if is_symlink(item.path):
continue
elif item.is_file() and item.name == 'ohos.build':
_files.append(item.path)
@@ -230,7 +230,7 @@ def get_file_type(file_path):
return 'unknown'
def is_symlik(file_path):
def is_symlink(file_path):
file_type = get_file_type(file_path)
if file_type == 'symlink':
link_target = os.readlink(file_path)