mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 02:11:19 -04:00
@@ -245,6 +245,7 @@ bool DecodePrivateSyscap(char *input, char (**output)[SINGLE_SYSCAP_LEN], int *o
|
||||
*bufferPos = '\0';
|
||||
if (sprintf_s(*outputArray, SINGLE_SYSCAP_LEN, "SystemCapability.%s", buffer) == -1) {
|
||||
free(outputArray);
|
||||
free(output);
|
||||
return false;
|
||||
}
|
||||
bufferPos = buffer;
|
||||
@@ -328,24 +329,25 @@ FREE_SYSCAP_OUT:
|
||||
static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo,
|
||||
cJSON *sysCapArray, const char *inputFile)
|
||||
{
|
||||
int32_t ret = -1;
|
||||
// trans to string format
|
||||
sysCapArray = cJSON_GetObjectItem(freeAfterDecodeRpcidInfo.rpcidRoot, "syscap");
|
||||
if (sysCapArray == NULL || !cJSON_IsArray(sysCapArray)) {
|
||||
PRINT_ERR("Get syscap failed. Input file: %s\n", inputFile);
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
freeAfterDecodeRpcidInfo.sysCapArraySize = cJSON_GetArraySize(sysCapArray);
|
||||
if (freeAfterDecodeRpcidInfo.sysCapArraySize < 0) {
|
||||
PRINT_ERR("Get syscap size failed. Input file: %s\n", inputFile);
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
// malloc for save os syscap index
|
||||
freeAfterDecodeRpcidInfo.osSysCapIndex = (uint16_t *)malloc(sizeof(uint16_t)
|
||||
* freeAfterDecodeRpcidInfo.sysCapArraySize);
|
||||
if (freeAfterDecodeRpcidInfo.osSysCapIndex == NULL) {
|
||||
PRINT_ERR("malloc failed.\n");
|
||||
return -1;
|
||||
}
|
||||
free(freeAfterDecodeRpcidInfo.osSysCapIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,10 +286,12 @@ int32_t CreatePCID(char *inputFile, char *outDirPath)
|
||||
ret += SetPriSyscap(pcidBuffer, jsonPriSyscapObj, privateCapSize, allPriSyscapStrLen);
|
||||
ret += SetPCIDHeader(pcidBuffer, jsonRootObj);
|
||||
if (ret != 0) {
|
||||
cJSON_Delete(jsonRootObj);
|
||||
return FreeAfterCreatePCID(pcidBuffer, allOsSyscapObj, contextBuffer, FREE_CREATE_PCID_BUFFER_OUT, ret);
|
||||
}
|
||||
|
||||
ret = CheckConvertedContextSaveAsFile(outDirPath, pcidBuffer, pcidLength, ret);
|
||||
cJSON_Delete(jsonRootObj);
|
||||
return FreeAfterCreatePCID(pcidBuffer, allOsSyscapObj, contextBuffer, FREE_CREATE_PCID_BUFFER_OUT, ret);
|
||||
}
|
||||
|
||||
@@ -520,6 +522,7 @@ int32_t DecodePCID(char *inputFile, char *outDirPath)
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("ConvertedContextSaveAsFile failed, outDirPath:%s, filename:%s\n", outDirPath, outputFileName);
|
||||
}
|
||||
free(strJson);
|
||||
return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,7 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath)
|
||||
|
||||
FREE_RPCID_ROOT:
|
||||
cJSON_Delete(rpcidRoot);
|
||||
free(convertedBuffer);
|
||||
FREE_CONTEXT_OUT:
|
||||
FreeContextBuffer(contextBuffer);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user