Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ccp4srs/ccp4srs_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ namespace ccp4srs {
n_alloc = 0;
}

Container ( const Container & ) = delete;
Container & operator = ( const Container & ) = delete;

virtual ~Container() {
empty();
}
Expand Down
24 changes: 17 additions & 7 deletions mmdb2/mmdb_io_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,17 +1090,27 @@ namespace mmdb {

Cnt = BufCnt + Count;
if (Cnt>BufLen) {
Cnt += BufInc;
IOB = new char[Cnt];
if (IOBuf) {
memcpy ( IOB,IOBuf,BufCnt );
delete[] IOBuf;
long newLen = (long)Cnt + (long)BufInc;
pstr oldBuf = IOBuf;
IOB = new char[newLen];
if ((IOB==NULL) && (newLen>0)) {
IOSuccess = false;
return false;
}
if ((oldBuf) && (BufCnt>0))
memcpy ( IOB,oldBuf,BufCnt );
IOBuf = IOB;
BufLen = Cnt;
BufLen = (word)newLen;
ownBuf = true;
if (oldBuf)
delete[] oldBuf;
}
if ((Count>0) && (IOBuf==NULL)) {
IOSuccess = false;
return false;
}
memcpy ( &(IOBuf[BufCnt]),Buffer,Count );
if (Count>0)
memcpy ( &(IOBuf[BufCnt]),Buffer,Count );
BufCnt += Count;
FLength = BufCnt;
IOSuccess = true;
Expand Down
17 changes: 10 additions & 7 deletions mmdb2/mmdb_math_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,18 @@
void Graph::AddVertex ( PVertex V ) {
int i;
PVertex * V1;
PVertex * oldVertex;

if (nAllVertices>=nVAlloc) {
nVAlloc += AllocPortion;
V1 = new PVertex[nVAlloc];
oldVertex = vertex;
nVAlloc += AllocPortion;
V1 = new PVertex[nVAlloc];
for (i=0;i<nAllVertices;i++)
V1[i] = vertex[i];
V1[i] = oldVertex[i];
for (i=nAllVertices;i<nVAlloc;i++)
V1[i] = NULL;
if (vertex) delete[] vertex;
vertex = V1;
if (oldVertex) delete[] oldVertex;
}
if (vertex[nAllVertices])
delete vertex[nAllVertices];
Expand Down Expand Up @@ -596,8 +598,6 @@
if (edge) delete[] edge;
edge = G1;
}
if (edge[nAllEdges])
delete edge[nAllEdges];
edge[nAllEdges] = G;
nAllEdges++;
nEdges = nAllEdges;
Expand Down Expand Up @@ -2216,10 +2216,13 @@
M1[i] = Match[i];
for (i=nMatches;i<nMAlloc;i++)
M1[i] = NULL;
if (Match) delete[] Match;
if (Match) {
delete[] Match;
Match = NULL;
}
Match = M1;
} else
nMatches--;

Check failure

Code scanning / CodeQL

Potential use after free Critical

Memory may have been previously freed by
delete[]
.
}

if (!Match[nMatches])
Expand Down
7 changes: 6 additions & 1 deletion mmdb2/mmdb_root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,10 @@ namespace mmdb {
Mdl[i] = model[i];
for (i=nModels;i<nM;i++)
Mdl[i] = NULL;
if (model) delete[] model;
if (model) {
delete[] model;
model = NULL;
}
model = Mdl;
nModels = nM;
if (Transfer) {
Expand All @@ -2049,6 +2052,8 @@ namespace mmdb {
}
}

if (!model)
return Error_GeneralError1;
if (!model[nM-1])
model[nM-1] = newModel();
model[nM-1]->SetMMDBManager ( PManager(this),nM );
Expand Down
9 changes: 5 additions & 4 deletions mmdb2/mmdb_xml_.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,23 +540,24 @@ namespace mmdb {
}

void XMLObject::AddObject ( PXMLObject XMLObject, int lenInc ) {
PPXMLObject obj1;
PPXMLObject obj1, oldObject;
int i;

if (!XMLObject) return;

if (nObjects>=nAlloc) {
if (lenInc<=0) lenInc = 1;
nAlloc += lenInc;
obj1 = new PXMLObject[nAlloc];
for (i=0;i<nObjects;i++)
obj1[i] = object[i];
for (i=nObjects;i<nAlloc;i++)
obj1[i] = NULL;
if (object) delete[] object;
object = obj1;
oldObject = object;
object = obj1;
if (oldObject) delete[] oldObject;
}

if (object[nObjects]) delete object[nObjects];
object[nObjects] = XMLObject;
XMLObject->SetParent ( this );
nObjects++;
Expand Down
2 changes: 1 addition & 1 deletion pisalib/chem_equilibrium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ long double mass1,M,dmass1,dmass2;
double lnC1,lnC2;
int n;

M = totalMass*species[speciesNo]->alpha;
M = static_cast<long double>(totalMass) * species[speciesNo]->alpha;

lnC1 = species[speciesNo]->lnC;
lnC2 = lnC1;
Expand Down
3 changes: 2 additions & 1 deletion pisalib/pisa_asmstock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace pisa {
if (t<0)
return UnknownType;

if (t>nAssemblies) {
if (t>=nAssemblies) {
n1 = t + 10;
A1 = new PAssembly[n1];
mmdb::GetVectorMemory ( c1,n1,0 );
Expand All @@ -117,6 +117,7 @@ namespace pisa {
mmdb::FreeVectorMemory ( count,0 );
count = c1;
nAssemblies = n1;
nAsmAlloc = n1;
}

if (!A[t]) {
Expand Down
6 changes: 4 additions & 2 deletions pisalib/pisa_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1883,14 +1883,16 @@ namespace pisa {
if (k<0) {

if (nMultSets>=nMultSetAlloc) {
PMultimerSet *oldMultSet;
nMultSetAlloc += 100;
US = new PMultimerSet[nMultSetAlloc];
for (i=0;i<nMultSets;i++)
US[i] = multSet[i];
for (i=nMultSets;i<nMultSetAlloc;i++)
US[i] = NULL;
delete[] multSet;
multSet = US;
oldMultSet = multSet;
multSet = US;
delete[] oldMultSet;
}

if (!multSet[nMultSets]) multSet[nMultSets] = new MultimerSet();
Expand Down
9 changes: 6 additions & 3 deletions ssm/ssm_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,15 @@
if (nVertices>=nVAlloc) {
nV1 = nVertices + 20;
V1 = new PVertex[nV1];
for (i=0;i<nVAlloc;i++)
for (i=0;i<nVertices;i++)
V1[i] = V[i];
for (i=nVAlloc;i<nV1;i++)
for (i=nVertices;i<nV1;i++)
V1[i] = NULL;
if (V) delete[] V;
if (V) {
delete[] V;
V = NULL;
}
V = V1;

Check failure

Code scanning / CodeQL

Potential use after free Critical

Memory may have been previously freed by
delete[]
.
nVAlloc = nV1;
}
V[nVertices++] = Vx;
Expand Down