Skip to content

Commit aeb1e36

Browse files
nikita240CalcProgrammer1
authored andcommitted
Fix memory leak in Nanoleaf Controller
1 parent e61b6cd commit aeb1e36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Controllers/NanoleafController/NanoleafController.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ void NanoleafController::UpdateLEDs(std::vector<RGBColor>& colors)
192192
}
193193

194194
external_control_socket.udp_write((char*)message, (size * 7) + 1);
195+
196+
free(message);
195197
}
196198
else if((model == NANOLEAF_CANVAS_MODEL)
197199
|| (model == NANOLEAF_SHAPES_MODEL))
@@ -230,6 +232,8 @@ void NanoleafController::UpdateLEDs(std::vector<RGBColor>& colors)
230232
}
231233

232234
external_control_socket.udp_write((char *)message, (size * 8) + 2);
235+
236+
free(message);
233237
}
234238
}
235239

@@ -252,7 +256,7 @@ void NanoleafController::StartExternalControl()
252256

253257
json response;
254258
if((APIRequest("PUT", location, "/api/v1/"+auth_token+"/effects", &request, &response) / 100) == 2)
255-
{
259+
{
256260
external_control_socket.udp_client(response["streamControlIpAddr"].get<std::string>().c_str(), std::to_string(response["streamControlPort"].get<int>()).c_str());
257261

258262
selectedEffect = NANOLEAF_DIRECT_MODE_EFFECT_NAME;

0 commit comments

Comments
 (0)