Skip to content

Commit

Permalink
[CID 335557]Fix use-after-free in http_admin
Browse files Browse the repository at this point in the history
  • Loading branch information
PengZheng committed Jan 1, 2024
1 parent ab7b7af commit 9a5602f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bundles/http_admin/http_admin/src/websocket_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 9a5602f

Please sign in to comment.