diff --git a/attributes/maestro-schema.c b/attributes/maestro-schema.c index acbf365b986c5d9fdd32259a64348068aab86a87..d08fe67b7095cf03bfb267215d1e911b40864504 100644 --- a/attributes/maestro-schema.c +++ b/attributes/maestro-schema.c @@ -2710,7 +2710,18 @@ mstro_attribute_entry_to_mapentry(const struct mstro_attribute_entry_ *entry, case MSTRO_STP_STR: case MSTRO_STP_REGEX: res->val->val_case = MSTRO__POOL__AVAL__VAL_STRING; - res->val->string = (char *)entry->val; + /* we need to duplicate strings, since the deallocation of + * protobuf messages descends into char* members, and so the + * entry in the dictionary where the entry is will be invalid + * when the message is deallocated (or vice versa) */ + res->val->string = strdup((char *)entry->val); + if(res->val->string==NULL) { + ERR("Failed to allocat string value for KV entry\n"); + free(res->val); + free(res); + s=MSTRO_NOMEM; + goto BAILOUT; + } break; case MSTRO_STP_BLOB: res->val->val_case = MSTRO__POOL__AVAL__VAL_BYTES;