mirror of
https://github.com/corda/corda.git
synced 2025-01-23 04:48:09 +00:00
fix memory management bugs in finder.cpp
This commit is contained in:
parent
756f58210a
commit
58dc32382d
@ -448,6 +448,7 @@ class JarElement: public Element {
|
|||||||
unsigned jarLength):
|
unsigned jarLength):
|
||||||
s(s),
|
s(s),
|
||||||
allocator(allocator),
|
allocator(allocator),
|
||||||
|
originalName(0),
|
||||||
name(0),
|
name(0),
|
||||||
urlPrefix_(name ? append(allocator, "jar:file:", name, "!/") : 0),
|
urlPrefix_(name ? append(allocator, "jar:file:", name, "!/") : 0),
|
||||||
sourceUrl_(name ? append(allocator, "file:", name) : 0),
|
sourceUrl_(name ? append(allocator, "file:", name) : 0),
|
||||||
@ -517,12 +518,14 @@ class JarElement: public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void dispose(unsigned size) {
|
virtual void dispose(unsigned size) {
|
||||||
if (originalName != name) {
|
if (name) {
|
||||||
allocator->free(originalName, strlen(originalName) + 1);
|
if (originalName != name) {
|
||||||
|
allocator->free(originalName, strlen(originalName) + 1);
|
||||||
|
}
|
||||||
|
allocator->free(name, strlen(name) + 1);
|
||||||
|
allocator->free(urlPrefix_, strlen(urlPrefix_) + 1);
|
||||||
|
allocator->free(sourceUrl_, strlen(sourceUrl_) + 1);
|
||||||
}
|
}
|
||||||
allocator->free(name, strlen(name) + 1);
|
|
||||||
allocator->free(urlPrefix_, strlen(urlPrefix_) + 1);
|
|
||||||
allocator->free(sourceUrl_, strlen(sourceUrl_) + 1);
|
|
||||||
if (index) {
|
if (index) {
|
||||||
index->dispose();
|
index->dispose();
|
||||||
}
|
}
|
||||||
@ -906,7 +909,9 @@ class MyFinder: public Finder {
|
|||||||
e = e->next;
|
e = e->next;
|
||||||
t->dispose();
|
t->dispose();
|
||||||
}
|
}
|
||||||
allocator->free(pathString, strlen(pathString) + 1);
|
if (pathString) {
|
||||||
|
allocator->free(pathString, strlen(pathString) + 1);
|
||||||
|
}
|
||||||
allocator->free(this, sizeof(*this));
|
allocator->free(this, sizeof(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user