Fix leak in test_interfaces.c (#381)
Fix leak in test_interfaces.c (#381)

* Fix leak in test_interaces.c

Before this fix when running test_interfaces:

==15142==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7fd778a99d38 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded38)
    #1 0x7fd77858a0f6 in rosidl_generator_c__String__Sequence__init ../../src/ros2/rosidl/rosidl_generator_c/src/string_functions.c:114
    #2 0x7fd7787a85cf in rosidl_generator_c__msg__StringArrays__init rosidl_generator_c/rosidl_generator_c/msg/string_arrays__functions.c:48
    #3 0x7fd7787a90d2 in rosidl_generator_c__msg__StringArrays__create rosidl_generator_c/rosidl_generator_c/msg/string_arrays__functions.c:264
    #4 0x560bf3da9991 in test_string_arrays ../../src/ros2/rosidl/rosidl_generator_c/test/test_interfaces.c:379
    #5 0x560bf3da7c00 in main ../../src/ros2/rosidl/rosidl_generator_c/test/test_interfaces.c:154
    #6 0x7fd7781b3b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7fd778a99d38 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded38)
    #1 0x7fd77858a0f6 in rosidl_generator_c__String__Sequence__init ../../src/ros2/rosidl/rosidl_generator_c/src/string_functions.c:114
    #2 0x7fd7787a85cf in rosidl_generator_c__msg__StringArrays__init rosidl_generator_c/rosidl_generator_c/msg/string_arrays__functions.c:48
    #3 0x7fd7787a90d2 in rosidl_generator_c__msg__StringArrays__create rosidl_generator_c/rosidl_generator_c/msg/string_arrays__functions.c:264
    #4 0x560bf3daa659 in test_string_arrays_default_value ../../src/ros2/rosidl/rosidl_generator_c/test/test_interfaces.c:448
    #5 0x560bf3da7c5d in main ../../src/ros2/rosidl/rosidl_generator_c/test/test_interfaces.c:159
    #6 0x7fd7781b3b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

... etc

SUMMARY: AddressSanitizer: 860 byte(s) leaked in 48 allocation(s).

After applying the fix:

Testing rosidl_generator_c message types...
Testing simple primitive message types...
Testing simple primitives with default values...
Testing string types...
Testing primitives unbounded arrays types...
Testing primitives bounded arrays types...
Testing primitives static arrays types...
Testing nested sub-messages...
Testing static_array_nested messages...
Testing bounded_array_nested messages...
Testing dynamic_array_nested messages...
Testing dynamic_array_primitives_nested messages...
Testing string arrays...
Testing string arrays with default values...
All tests were good!

Signed-off-by: Thomas Moulard <c497402a3dadb29b8ae64e0cc05b0fff58b28660@amazon.com>

* Check StringArrays is not null after invoking create

Signed-off-by: Thomas Moulard <c497402a3dadb29b8ae64e0cc05b0fff58b28660@amazon.com>

ros2/rosidl,ros2/rosidl,ros2/rosidl,ros2/rosidl