You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2024/01/01 04:44:58 UTC
(celix) 01/02: [CID 335557]Fix use-after-free in http_admin
This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch feature/coverity-fix
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 9a5602fbd822239fd94877ef768a87809afd5f35
Author: PengZheng <ho...@gmail.com>
AuthorDate: Mon Jan 1 12:41:29 2024 +0800
[CID 335557]Fix use-after-free in http_admin
---
bundles/http_admin/http_admin/src/websocket_admin.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/bundles/http_admin/http_admin/src/websocket_admin.c b/bundles/http_admin/http_admin/src/websocket_admin.c
index 2cd8a453..28779683 100644
--- a/bundles/http_admin/http_admin/src/websocket_admin.c
+++ b/bundles/http_admin/http_admin/src/websocket_admin.c
@@ -27,6 +27,7 @@
#include "websocket_admin.h"
#include "celix_compiler.h"
+#include "celix_stdlib_cleanup.h"
#include "celix_utils_api.h"
struct websocket_admin_manager {
@@ -41,7 +42,7 @@ struct websocket_admin_manager {
websocket_admin_manager_t *websocketAdmin_create(celix_bundle_context_t *context, struct mg_context *svr_ctx) {
celix_status_t status;
- websocket_admin_manager_t *admin = (websocket_admin_manager_t *) calloc(1, sizeof(websocket_admin_manager_t));
+ celix_autofree websocket_admin_manager_t *admin = (websocket_admin_manager_t *) calloc(1, sizeof(websocket_admin_manager_t));
if (admin == NULL) {
return NULL;
@@ -53,10 +54,10 @@ websocket_admin_manager_t *websocketAdmin_create(celix_bundle_context_t *context
if(status != CELIX_SUCCESS) {
//No need to destroy other things
- free(admin);
+ return NULL;
}
- return admin;
+ return celix_steal_ptr(admin);
}
void websocketAdmin_destroy(websocket_admin_manager_t *admin) {