Skip to content

Commit 7d8d717

Browse files
committed
free memory
1 parent 5f36748 commit 7d8d717

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pe-parser-library/src/parse.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct reloc {
6464

6565
struct debugent {
6666
std::uint32_t type;
67-
bounded_buffer data;
67+
bounded_buffer *data;
6868
};
6969

7070
#define SYMBOL_NAME_OFFSET(sn) (static_cast<std::uint32_t>(sn.data >> 32))
@@ -1896,7 +1896,7 @@ bool getDebugDir(parsed_pe *p) {
18961896

18971897
auto dataofft = static_cast<std::uint32_t>(rawData - dataSec.sectionBase);
18981898
ent.type = curEnt.Type;
1899-
ent.data = *makeBufferFromPointer(
1899+
ent.data = makeBufferFromPointer(
19001900
reinterpret_cast<std::uint8_t *>(dataSec.sectionData->buf + dataofft),
19011901
curEnt.SizeOfData);
19021902

@@ -2603,6 +2603,12 @@ void DestructParsedPE(parsed_pe *p) {
26032603
}
26042604
}
26052605

2606+
for (debugent d : p->internal->debugdirs) {
2607+
if (d.data != nullptr) {
2608+
deleteBuffer(d.data);
2609+
}
2610+
}
2611+
26062612
delete p->internal;
26072613
delete p;
26082614
return;
@@ -2638,7 +2644,7 @@ void IterDebugs(parsed_pe *pe, iterDebug cb, void *cbd) {
26382644
std::vector<debugent> &l = pe->internal->debugdirs;
26392645

26402646
for (debugent &d : l) {
2641-
if (cb(cbd, d.type, &d.data) != 0) {
2647+
if (cb(cbd, d.type, d.data) != 0) {
26422648
break;
26432649
}
26442650
}

0 commit comments

Comments
 (0)