View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002178 | OpenFOAM | Patch | public | 2016-08-03 15:57 | 2016-08-03 19:46 |
Reporter | Assigned To | henry | |||
Priority | normal | Severity | crash | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Platform | any | ||||
Product Version | dev | ||||
Fixed in Version | dev | ||||
Summary | 0002178: segfault is possible in FixedList constructor (based on code inspection) | ||||
Description | In the constructor FixedList<T, Size>::FixedList(const UList<T>& lst) checkSize(lst.size()); for (unsigned i=0; i<Size; i++) { v_[i] = lst[i]; } The checkSize() tests that [0 <= lst.size() <= Size] prior to the loop. But when lst.size() < Size then lst[i] is not guaranteed to be addressable throughout the 0-Size range. The same applies to the '=' operator. The constructor and operator= from SLList<T>& are OK since they terminate as soon as running out of items. The size() check in FixedList::writeEntry() is redundant. | ||||
Tags | No tags attached. | ||||
|
checkSize() should check equality 'if (unsigned(size) == Size)', I will make this change. > The size() check in FixedList::writeEntry() is redundant. Why? It looks like a useful quick rejection to me. |
|
Because by definition, size() is Size for FixedList and this is positive non-zero: static_assert ( Size && Size <= INT_MAX, "Size must be positive (non-zero) and also fit as a signed value" ); It is a compile-time 'true', not a quick rejection, and thus redundant. Sure the compiler will remove it, but we could too. Maybe also less cluttered to have this too: const word listToken("List<" + word(pTraits<T>::typeName) + '>'); if (token::compound::isCompound(listToken)) { os << listToken << token::SPACE; } Sure the compiler can manage either way, but I think this looks less noisy. |
|
Resolved by commit 232a2a092c84f6aba8a56dcdf51d75daa69e78bc |
Date Modified | Username | Field | Change |
---|---|---|---|
2016-08-03 15:57 |
|
New Issue | |
2016-08-03 16:22 | henry | Note Added: 0006633 | |
2016-08-03 17:07 |
|
Note Added: 0006636 | |
2016-08-03 19:46 | henry | Note Added: 0006643 | |
2016-08-03 19:46 | henry | Status | new => resolved |
2016-08-03 19:46 | henry | Fixed in Version | => dev |
2016-08-03 19:46 | henry | Resolution | open => fixed |
2016-08-03 19:46 | henry | Assigned To | => henry |