Fixed a memory corruption. Coverity issue: 1265729: Out-of-bounds access.

This commit is contained in:
Ward Fisher 2015-07-29 14:58:34 -06:00
parent 679048ee2a
commit 1f5e6379e4

View File

@ -1165,9 +1165,9 @@ ncio_spx_get(ncio *const nciop,
}
{
const size_t rndup = extent % X_ALIGN;
if(rndup != 0)
extent += X_ALIGN - rndup;
const size_t rndup = extent % X_ALIGN;
if(rndup != 0)
extent += X_ALIGN - rndup;
}
assert(offset % X_ALIGN == 0);
@ -1183,7 +1183,7 @@ ncio_spx_get(ncio *const nciop,
pxp->bf_extent = 0;
}
assert(pxp->bf_extent == 0);
pxp->bf_base = malloc(extent);
pxp->bf_base = malloc(extent+1);
if(pxp->bf_base == NULL)
return ENOMEM;
pxp->bf_extent = extent;