From 01dcf2b1c50b574436ae72ff6577a65615cba7a4 Mon Sep 17 00:00:00 2001 From: CoolSpy3 <55305038+CoolSpy3@users.noreply.github.com> Date: Wed, 28 Aug 2024 21:28:33 -0700 Subject: [PATCH 1/5] fix crash when wb_supervisor_field_get_name is called with NULL --- src/controller/c/supervisor.c | 3 +++ tests/api/controllers/supervisor_field/supervisor_field.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/controller/c/supervisor.c b/src/controller/c/supervisor.c index b20574914ce..e7a6dc47a19 100644 --- a/src/controller/c/supervisor.c +++ b/src/controller/c/supervisor.c @@ -2831,6 +2831,9 @@ const double *wb_supervisor_virtual_reality_headset_get_orientation() { } const char *wb_supervisor_field_get_name(WbFieldRef field) { + if (!check_field(field, __FUNCTION__, WB_NO_FIELD, false, NULL, false, false)) + return ""; + return field->name; } diff --git a/tests/api/controllers/supervisor_field/supervisor_field.c b/tests/api/controllers/supervisor_field/supervisor_field.c index 5df8e00cb41..ac11085738d 100644 --- a/tests/api/controllers/supervisor_field/supervisor_field.c +++ b/tests/api/controllers/supervisor_field/supervisor_field.c @@ -25,6 +25,11 @@ int main(int argc, char **argv) { int i; double d; + ts_assert_string_equal(wb_supervisor_field_get_name(NULL), "", "wb_supervisor_field_get_name(NULL) should return the empty string"); + ts_assert_int_equal(wb_supervisor_field_get_type(NULL), 0, "wb_supervisor_field_get_type(NULL) should return 0"); + ts_assert_string_equal(wb_supervisor_field_get_type_name(NULL), "", "wb_supervisor_field_get_type_name(NULL) should return the empty string"); + ts_assert_int_equal(wb_supervisor_field_get_count(NULL), -1, "wb_supervisor_field_get_count(NULL) should return -1"); + root = wb_supervisor_node_get_root(); ts_assert_pointer_not_null(root, "Root node is not found"); From 7bab6f388d2e2b0616016ccb2cd8fdddbd47f9ed Mon Sep 17 00:00:00 2001 From: CoolSpy3 <55305038+CoolSpy3@users.noreply.github.com> Date: Wed, 28 Aug 2024 21:31:15 -0700 Subject: [PATCH 2/5] update changelog --- docs/reference/changelog-r2024.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/changelog-r2024.md b/docs/reference/changelog-r2024.md index e27c7cb6361..63fb156ba17 100644 --- a/docs/reference/changelog-r2024.md +++ b/docs/reference/changelog-r2024.md @@ -28,3 +28,4 @@ Released on December **th, 2023. - Fixed connection errors when using long robot names in some environments ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - Fixed crash on macos when closing Webots under some circumstances ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - Fixed error on macos when when putting displays and cameras in separate windows ([#6635](https://github.com/cyberbotics/webots/pull/6635)). + - Fixed crash when `wb_supervisor_field_get_name` is called with NULL ([#6647](https://github.com/cyberbotics/webots/pull/6647)) From ffae7fa21552c2b447492aec593aafde36ca0e4b Mon Sep 17 00:00:00 2001 From: CoolSpy3 <55305038+CoolSpy3@users.noreply.github.com> Date: Wed, 28 Aug 2024 21:40:52 -0700 Subject: [PATCH 3/5] run clang-format --- tests/api/controllers/supervisor_field/supervisor_field.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/api/controllers/supervisor_field/supervisor_field.c b/tests/api/controllers/supervisor_field/supervisor_field.c index ac11085738d..3e5bbfe0265 100644 --- a/tests/api/controllers/supervisor_field/supervisor_field.c +++ b/tests/api/controllers/supervisor_field/supervisor_field.c @@ -25,9 +25,11 @@ int main(int argc, char **argv) { int i; double d; - ts_assert_string_equal(wb_supervisor_field_get_name(NULL), "", "wb_supervisor_field_get_name(NULL) should return the empty string"); + ts_assert_string_equal(wb_supervisor_field_get_name(NULL), "", + "wb_supervisor_field_get_name(NULL) should return the empty string"); ts_assert_int_equal(wb_supervisor_field_get_type(NULL), 0, "wb_supervisor_field_get_type(NULL) should return 0"); - ts_assert_string_equal(wb_supervisor_field_get_type_name(NULL), "", "wb_supervisor_field_get_type_name(NULL) should return the empty string"); + ts_assert_string_equal(wb_supervisor_field_get_type_name(NULL), "", + "wb_supervisor_field_get_type_name(NULL) should return the empty string"); ts_assert_int_equal(wb_supervisor_field_get_count(NULL), -1, "wb_supervisor_field_get_count(NULL) should return -1"); root = wb_supervisor_node_get_root(); From a19bfc957b44fdf1592d2584f944312b4fe166f6 Mon Sep 17 00:00:00 2001 From: CoolSpy3 Date: Fri, 30 Aug 2024 00:11:19 -0700 Subject: [PATCH 4/5] use past-tense in changelog --- docs/reference/changelog-r2024.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/changelog-r2024.md b/docs/reference/changelog-r2024.md index 63fb156ba17..1254c4d3565 100644 --- a/docs/reference/changelog-r2024.md +++ b/docs/reference/changelog-r2024.md @@ -28,4 +28,4 @@ Released on December **th, 2023. - Fixed connection errors when using long robot names in some environments ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - Fixed crash on macos when closing Webots under some circumstances ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - Fixed error on macos when when putting displays and cameras in separate windows ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - - Fixed crash when `wb_supervisor_field_get_name` is called with NULL ([#6647](https://github.com/cyberbotics/webots/pull/6647)) + - Fixed crash when `wb_supervisor_field_get_name` was called with NULL ([#6647](https://github.com/cyberbotics/webots/pull/6647)) From 7495781f11f335267785faff1df3a89220fc0ea2 Mon Sep 17 00:00:00 2001 From: CoolSpy3 <55305038+CoolSpy3@users.noreply.github.com> Date: Sun, 1 Sep 2024 10:26:42 -0700 Subject: [PATCH 5/5] add period to changelog Co-authored-by: Olivier Michel --- docs/reference/changelog-r2024.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/changelog-r2024.md b/docs/reference/changelog-r2024.md index 1254c4d3565..16c867eb9bc 100644 --- a/docs/reference/changelog-r2024.md +++ b/docs/reference/changelog-r2024.md @@ -28,4 +28,4 @@ Released on December **th, 2023. - Fixed connection errors when using long robot names in some environments ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - Fixed crash on macos when closing Webots under some circumstances ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - Fixed error on macos when when putting displays and cameras in separate windows ([#6635](https://github.com/cyberbotics/webots/pull/6635)). - - Fixed crash when `wb_supervisor_field_get_name` was called with NULL ([#6647](https://github.com/cyberbotics/webots/pull/6647)) + - Fixed crash when `wb_supervisor_field_get_name` was called with NULL ([#6647](https://github.com/cyberbotics/webots/pull/6647)).