From 13844f839d1a1d22aa1dfbc9774ba311a6b62193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=9F=E6=B0=91?= Date: Wed, 18 May 2022 13:34:48 +0800 Subject: [PATCH] fix the bug that free the resoruces while the exception return NULL. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张伟民 --- standard/appspawn_service.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/standard/appspawn_service.c b/standard/appspawn_service.c index dfd7f994..da34ee42 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -459,6 +459,11 @@ static int CreateHashForApp(AppSpawnContentExt *appSpawnContent) return 0; } +static void CloseStreamTask(AppSpawnContentExt *appSpawnContent) +{ + LE_CloseStreamTask(LE_GetDefaultLoop(), appSpawnContent->server); +} + AppSpawnContent *AppSpawnCreateContent(const char *socketName, char *longProcName, uint32_t longProcNameLen, int mode) { APPSPAWN_CHECK(LE_GetDefaultLoop() != NULL, return NULL, "Invalid default loop"); @@ -503,7 +508,9 @@ AppSpawnContent *AppSpawnCreateContent(const char *socketName, char *longProcNam return NULL, "Failed to create socket for %s", path); // create socket ret = chmod(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); - APPSPAWN_CHECK(ret == 0, free(appSpawnContent); + APPSPAWN_CHECK(ret == 0, + CloseStreamTask(appSpawnContent); + free(appSpawnContent); return NULL, "Failed to chmod %s, err %d. ", path, errno); APPSPAWN_LOGI("AppSpawnCreateContent path %s fd %d", path, LE_GetSocketFd(appSpawnContent->server)); } -- Gitee