diff --git a/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp b/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp index 88c0b17f265f09b72c92c5d5106e7243c146e076..9559661a845f6102cb76cab255e0f9f5eac97518 100755 --- a/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp +++ b/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp @@ -51,27 +51,18 @@ void ExecuteGetInfo(void* data) JSIValue thisVal = params->thisVal; char* brand = GetBrand(); if (brand == nullptr) { - NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); - JSI::ReleaseValueList(args, thisVal, ARGS_END); - delete params; - return; + goto _fail; } char* manufacture = GetManufacture(); if (manufacture == nullptr) { free(brand); - NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); - JSI::ReleaseValueList(args, thisVal, ARGS_END); - delete params; - return; + goto _fail; } char* model = GetProductModel(); if (model == nullptr) { free(brand); free(manufacture); - NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); - JSI::ReleaseValueList(args, thisVal, ARGS_END); - delete params; - return; + goto _fail; } JSIValue result = JSI::CreateObject(); JSI::SetStringProperty(result, "brand", brand); @@ -88,6 +79,12 @@ void ExecuteGetInfo(void* data) JSI::ReleaseValueList(args, thisVal, result, ARGS_END); delete params; params = nullptr; + return; +_fail: + NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); + JSI::ReleaseValueList(args, thisVal, ARGS_END); + delete params; + return; } }