Skip to content
Snippets Groups Projects
Verified Commit 5db070e9 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Bytecode: fix inconsistency in memory manager

The variable “gap” is compared to zero, so the intent probably was that it
could be negative. But size_t is an unsigned type. Rather use a signed type.
parent 6ae86024
Branches
Tags
No related merge requests found
/*
* Copyright © 2007-2021 Dynare Team
* Copyright © 2007-2022 Dynare Team
*
* This file is part of Dynare.
*
......@@ -99,10 +99,10 @@ void
Mem_Mngr::mxFree_NZE(void *pos)
{
unsigned int i;
size_t gap;
ptrdiff_t gap;
for (i = 0; i < Nb_CHUNK; i++)
{
gap = (reinterpret_cast<size_t>(pos)-reinterpret_cast<size_t>(NZE_Mem_add[i*CHUNK_BLCK_SIZE]))/sizeof(NonZeroElem);
gap = (reinterpret_cast<ptrdiff_t>(pos)-reinterpret_cast<ptrdiff_t>(NZE_Mem_add[i*CHUNK_BLCK_SIZE]))/sizeof(NonZeroElem);
if (gap < CHUNK_BLCK_SIZE && gap >= 0)
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment