Fully init TF_TString in order to mitigate potential msan false positives.

Prior to this change, TF_TString_Init intentionally only initialized the first
2 bytes of a 24 byte struct.  In some situations, where a temporary TF_TString
struct is initialized via TF_TString_Init and subsequently copied, the copying
of the uninitialized data may result in an msan use-of-uninitialized-value
error.

PiperOrigin-RevId: 320133690
Change-Id: I995ba629c4cb0b2a85a25c277caa74cf2dbc3bc3
This commit is contained in:
Dero Gharibian 2020-07-07 23:33:28 -07:00 committed by TensorFlower Gardener
parent faab6925c9
commit 89b2b97856

View File

@ -169,8 +169,7 @@ static inline size_t TF_TString_ToInternalSizeT(size_t size,
}
static inline void TF_TString_Init(TF_TString *str) {
str->u.smll.size = 0;
str->u.smll.str[0] = '\0';
memset(str->u.raw.raw, 0, sizeof(TF_TString_Raw));
}
static inline void TF_TString_Dealloc(TF_TString *str) {