Skip to content

Commit

Permalink
* FIX [rest api] fix memleak in bridge unsub.
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann0222 <yukang.wei@emqx.io>
  • Loading branch information
OdyWayne committed Sep 21, 2023
1 parent 416b962 commit 7ff960f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions nanomq/rest_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -3707,6 +3707,8 @@ post_mqtt_bridge_unsub(http_msg *msg, const char *name)
node->sub_count--;
nng_free(sub_topic->remote_topic,
sub_topic->remote_topic_len);
nng_free(sub_topic->local_topic,
sub_topic->local_topic_len);
nng_free(sub_topic, sizeof(topics));
break;
}
Expand Down
7 changes: 3 additions & 4 deletions nanomq/tests/http_server_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ test_put_bridges_unsub()
"'http://localhost:8081/api/v4/bridges/unsub/emqx' "
"--basic -u admin_test:pw_test -d '{"
"\"data\": {"
"\"unsubscription\": [{\"remote_topic\": \"cmd/topic1\", \"local_topic\": \"cmd_lo/topic1\"},"
"{\"remote_topic\": \"cmd/topic2\", \"local_topic\": \"cmd_lo/topic2\"}],"
"\"unsubscription\": [{\"topic\": \"cmd/topic1\"},"
"{\"topic\": \"cmd/topic2\"}],"
"\"unsub_properties\": {\"user_properties\": [{\"key\": "
"\"key1\",\"value\": \"value1\"},{\"key\": "
"\"key2\",\"value\": \"value2\"}]}}}'";
Expand Down Expand Up @@ -639,9 +639,8 @@ main()

assert(test_get_bridges());
assert(test_get_bridge());
// TODO: rest api need change for topic reflection in bridge.
assert(test_put_bridges_sub());
// assert(test_put_bridges_unsub()); // bridge unsub has to change for topic reflection
assert(test_put_bridges_unsub()); // the usage of unsub rest api may need further discussion.
assert(test_put_bridges());

assert(test_post_rules());
Expand Down

0 comments on commit 7ff960f

Please sign in to comment.