From 4121624750b31988aacf9ccc70cf0c258d23e25a Mon Sep 17 00:00:00 2001 From: Xiaofeng Meng Date: Thu, 23 Oct 2025 18:31:15 +0200 Subject: [PATCH] fix --- libbbfdm-api/legacy/dmapi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libbbfdm-api/legacy/dmapi.c b/libbbfdm-api/legacy/dmapi.c index d5270eef..06bfdfd3 100644 --- a/libbbfdm-api/legacy/dmapi.c +++ b/libbbfdm-api/legacy/dmapi.c @@ -409,12 +409,18 @@ static char *bbfdm_resolve_external_reference_via_dmmap(struct dmctx *ctx, const * We need to replace * with the parent instance number */ for (size_t i = 0; i < count; i++) { + /* Skip empty parts (e.g., trailing empty string from final dot) */ + if (strlen(parts[i]) == 0) + continue; if (i > 0 && strcmp(parts[i], "*") == 0) { dmuci_get_value_by_section_string(dmmap_obj, parts[i - 1], &option_value); - path_offset += snprintf(reconstructed_path + path_offset, - sizeof(reconstructed_path) - path_offset, - "%s.", option_value); + /* Only add if option_value is valid and not empty */ + if (option_value && strlen(option_value) > 0) { + path_offset += snprintf(reconstructed_path + path_offset, + sizeof(reconstructed_path) - path_offset, + "%s.", option_value); + } continue; }