STYLE: avoid potential deadlock when resizing from zero-sized list

- not yet triggered by any code, but avoid anyhow
This commit is contained in:
Mark Olesen
2019-12-10 09:53:41 +01:00
parent c2123452b1
commit 98b79faddb
2 changed files with 5 additions and 1 deletions

View File

@ -163,6 +163,8 @@ inline T& Foam::List<T>::newElmt(const label i)
if (i >= n)
{
if (!n) n = 1; // Avoid dead-lock when starting from zero-sized
do
{
n *= 2;

View File

@ -114,8 +114,10 @@ void Foam::ITstream::reserveCapacity
label n = tokenList::size();
if (nElem >= n)
if (nElem > n)
{
if (!n) n = 1; // Avoid dead-lock when starting from zero-sized
do
{
n *= 2;