Commit ab616c05 authored by Kirill Terekhov's avatar Kirill Terekhov

Add missing asserts for malloc

+prevent heap overflow due to big arrays in OldDrawGrid
parent bfe393fd
......@@ -106,7 +106,7 @@ void printtext(const char * fmt, ... )
{
unsigned int i;
char stext[1048576];
char stext[131072];
va_list ap;
if ( fmt == NULL ) return;
va_start(ap,fmt);
......@@ -2110,6 +2110,7 @@ class kdtree
case 2: qsort(set,size,sizeof(entry),cmpElements2);break;
}
children = static_cast<kdtree *>(malloc(sizeof(kdtree)*2));//new kdtree[2];
assert(children != NULL);
children[0].marked = 0;
children[0].children = NULL;
children[0].set = set;
......@@ -3144,6 +3145,7 @@ class kdtree_picker
case 2: qsort(set,size,sizeof(entry),cmpElements2);break;
}
children = static_cast<kdtree_picker *>(malloc(sizeof(kdtree_picker)*2));//new kdtree_picker[2];
assert(children != NULL);
children[0].children = NULL;
children[0].set = set;
children[0].size = size/2;
......@@ -4108,8 +4110,8 @@ double display_elem_info(Element e, double top, double left, double interval)
{
if( e->HaveData(*t) )
{
char str[1048576];
char temp[1048576];
char str[131072];
char temp[131072];
str[0] = '\0';
int dsize;
switch(t->GetDataType())
......
......@@ -2355,6 +2355,7 @@ namespace INMOST
void Mesh::AllocateSparseData(void * & q, const Tag & tag)
{
q = calloc(1,tag.GetRecordSize());
assert(q != NULL);
#if defined(USE_AUTODIFF)
if( tag.GetDataType() == DATA_VARIABLE && tag.GetSize() != ENUMUNDEF )
{
......
......@@ -689,12 +689,14 @@ namespace INMOST
int n;
input_ord >> n;
ord = (int *) malloc(sizeof(int) * n);
assert(ord != NULL);
for (int i=0; i<n; i++) input_ord >> ord[i];
int nbl;
input_ord >> nbl;
if( nbl != size ) throw -3;
int * ibl;
ibl = (int *) malloc(sizeof(int) * (nbl+1));
assert(ibl != NULL);
for (int i=0; i<nbl+1; i++) input_ord >> ibl[i];
if( mbeg == ENUMUNDEF ) mbeg = ibl[rank];
if( mend == ENUMUNDEF ) mend = ibl[rank+1];
......@@ -939,12 +941,14 @@ namespace INMOST
int n;
input_ord >> n; // check if( n == line )
ord = (int *) malloc(sizeof(int) * n);
assert(ord != NULL);
for (int i=0; i<n; i++) input_ord >> ord[i];
int nbl;
input_ord >> nbl;
if( nbl != size ) throw -3;
int * ibl;
ibl = (int *) malloc(sizeof(int) * (nbl+1));
assert(ibl != NULL);
for (int i=0; i<nbl+1; i++) input_ord >> ibl[i];
if( mbeg == ENUMUNDEF ) mbeg = (unsigned int) ibl[rank];
if( mend == ENUMUNDEF ) mend = (unsigned int) ibl[rank + 1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment