process return value from sprintf_s

Signed-off-by: Cai Xincheng <caixincheng@huawei.com>
This commit is contained in:
Cai Xincheng 2024-07-09 18:57:04 +08:00
parent 219b852785
commit 47d6a83ad8

View File

@ -30,7 +30,10 @@ namespace Asset {
#define NAPI_THROW_INVALID_ARGUMENT(env, format, arg...) \
do { \
char msg[MAX_MESSAGE_LEN] = { 0 }; \
(void)sprintf_s(msg, MAX_MESSAGE_LEN, format, ##arg); \
if ((sprintf_s(msg, MAX_MESSAGE_LEN, format, ##arg)) == -1) { \
LOGE("[FATAL][NAPI]Failed to create message string."); \
break; \
} \
LOGE("[FATAL][NAPI]%{public}s", (msg)); \
napi_throw((env), CreateJsError((env), SEC_ASSET_INVALID_ARGUMENT, (msg))); \
} while (0)