[yaml parser] Fix FQN=//node_name when ns is / (#299)

* Fix FQN=//node_name when ns is /

* Check end of string for ns sep

* Add regression test
This commit is contained in:
dhood 2018-09-21 14:50:48 -07:00 committed by GitHub
parent 0a6d9186e8
commit f1293b7d3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 1 deletions

View file

@ -187,7 +187,14 @@ static rcl_ret_t add_name_to_ns(
ns_len = strlen(cur_ns);
name_len = strlen(name);
sep_len = strlen(sep_str);
tot_len = ns_len + name_len + sep_len + 1U;
// Check the last sep_len characters of the current NS against the separator string.
if (strcmp(cur_ns + ns_len - sep_len, sep_str) == 0) {
// Current NS already ends with the separator: don't put another separator in.
sep_len = 0;
sep_str = "";
}
tot_len = ns_len + sep_len + name_len + 1U;
if (tot_len > MAX_STRING_SIZE) {
RCL_SET_ERROR_MSG("New namespace string is exceeding max string size",