Repository navigation
fix potential memory leaks in fileio.c and semantics.c - #199
Conversation
|
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. |
1bf46ef to
aaf76bb
Compare
|
@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 |
aaf76bb to
1f79d86
Compare
|
@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 fromprefixtopathifprefix_lenis greater than 0, so copying from a potentially null pointer is avoided. Insemantics.c,index.lenis set accordingly based onindex.typeso that the former variable will always be initialized.