diff --git a/docs/reference/changelog-r2025.md b/docs/reference/changelog-r2025.md index 8dcb0004235..99dd770f49c 100644 --- a/docs/reference/changelog-r2025.md +++ b/docs/reference/changelog-r2025.md @@ -3,6 +3,7 @@ ## Webots R2025b - Bug Fixes - Fixed a bug preventing the `webots-controller` executable from running on arm-based mac devices ([#6806](https://github.com/cyberbotics/webots/pull/6806)). + - Fixed a bug causing Webots to crash when multiple sounds were used with a [Speaker](speaker.md) node ([#6843](https://github.com/cyberbotics/webots/pull/6843)). ## Webots R2025a Released on January 31st, 2025. diff --git a/src/controller/c/speaker.c b/src/controller/c/speaker.c index cd11ce8e3c6..32e02cd1118 100644 --- a/src/controller/c/speaker.c +++ b/src/controller/c/speaker.c @@ -258,17 +258,17 @@ static void speaker_write_request(WbDevice *d, WbRequest *r) { request_write_char(r, 1); else request_write_char(r, 0); - } - request_write_int32(r, sound->upload_size); - if (sound->upload_size) { - /* Sound data available to stream, send it one time and discard it. - * Webots will cache the data inside the device. - */ - request_write_data(r, sound->upload_data, sound->upload_size); - free(sound->upload_data); - sound->upload_data = NULL; - sound->upload_size = 0; + request_write_int32(r, sound->upload_size); + if (sound->upload_size) { + /* Sound data available to stream, send it one time and discard it. + * Webots will cache the data inside the device. + */ + request_write_data(r, sound->upload_data, sound->upload_size); + free(sound->upload_data); + sound->upload_data = NULL; + sound->upload_size = 0; + } } sound->need_update = false;