SOPC_String_AttachFrom is not robust and may lead to bad pointer
SOPC_String_AttachFrom
makes a 'shallow' copy of another String. If the reference (src) string is cleared before the copy, then the copy data
field point to invalid memory.
There are several options:
- Do not change anything and rely on function specification
- Somehow count the references and :
- ensure that no shallow copy is living after the initial value ,
- delete the Data pointer when no more reference exit
However, the same question could arise for SOPC_String_AttachFromCstring
, which can hardly be protected: Is it better to protect one function or keep consistent behaviour between both?
Edited by Jérémie Chabod