Closed Adsun701 closed 3 years ago
Copy operation: yes, that is technically undefined behaviour for null pointers regardless of length. Fine to fix though it hardly matters in praxis.
index: I don't recall what the len field is used for - but is not used with coerce. I'm not sure if it semantically makes sense to assing a length for numerics if the length field is not set elsewhere for numerics.
However, the index value ought to be zero initialized.
@mikkelfj Fixed with index.len set to 0.
I just researched in parser.c. It seems that the v->len is only used with type information where scalar types have length 1 and fixed length arrays can have other lengths. For normal integer parsing, the length field is not used and most likely defaults to zero. I think the length field was added relatively late to handle fixed length arrays.
Thus, your latest change is fine, but I think leaving the code as it were is more correct if you initialize with fb_value_t index = { 0 };
.
@mikkelfj Fixed, thanks for the input.
Thanks
This fixes potential memory leaks that were detected by a quick run of cppcheck. In
fileio.c
,memcpy()
will only copy fromprefix
topath
ifprefix_len
is greater than 0, so copying from a potentially null pointer is avoided. Insemantics.c
,index.len
is set accordingly based onindex.type
so that the former variable will always be initialized.