]> granicus.if.org Git - esp-idf/commitdiff
wifi_prov_mgr : Free memory allocated by cJSON_Print
authorAnurag Kar <anurag.kar@espressif.com>
Fri, 28 Jun 2019 06:42:42 +0000 (12:12 +0530)
committerbot <bot@espressif.com>
Fri, 28 Jun 2019 07:49:03 +0000 (07:49 +0000)
components/wifi_provisioning/src/manager.c

index af7991fa769b8f52b5797ab31c1fe01a2128ba9a..41b998463caf7380b98e7c8f8c5add7126867bb0 100644 (file)
@@ -284,7 +284,9 @@ static esp_err_t wifi_prov_mgr_start_service(const char *service_name, const cha
 
     /* Set version information / capabilities of provisioning service and application */
     cJSON *version_json = wifi_prov_get_info_json();
-    ret = protocomm_set_version(prov_ctx->pc, "proto-ver", cJSON_Print(version_json));
+    char *version_str = cJSON_Print(version_json);
+    ret = protocomm_set_version(prov_ctx->pc, "proto-ver", version_str);
+    free(version_str);
     cJSON_Delete(version_json);
     if (ret != ESP_OK) {
         ESP_LOGE(TAG, "Failed to set version endpoint");