Code: Select all
============================================================================
=== Test Sequence 9 (Objects Factory)
----------------------------------------------------------------------------
--- Test Case 9.1 (Objects Registry)
--- Result: FAILURE (#3 [] "can register")
----------------------------------------------------------------------------
--- Test Case 9.2 (Dynamic Buffers Factory)
**** Unhandled Exception Here
The duplicate name register test is failing. This appears to be due to dyn_list_find relying on a null terminated string (when strlen < CH_CFG_FACTORY_MAX_NAMES_LENGTH) by the use of strncmp.
The following change to copy_name fixes the bug and allows all tests to pass:
Code: Select all
diff --git a/os/oslib/src/chfactory.c b/os/oslib/src/chfactory.c
index 4b858a32c..69bb388ef 100644
--- a/os/oslib/src/chfactory.c
+++ b/os/oslib/src/chfactory.c
@@ -92,6 +92,10 @@ static void copy_name(const char *sp, char *dp) {
sp++;
dp++;
}
+
+ if (i < CH_CFG_FACTORY_MAX_NAMES_LENGTH) {
+ *dp = '\0';
+ }
}
static inline void dyn_list_init(dyn_list_t *dlp) {