Skip to content

Commit 221a58d

Browse files
T0ny0xlz
authored andcommitted
fix memory leak in DumpDepthPacketProcessor
1 parent a01c4a6 commit 221a58d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/depth_packet_processor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,23 @@ const float* DumpDepthPacketProcessor::getZTable() { return ztable_; }
159159
const short* DumpDepthPacketProcessor::getLookupTable() { return lut_; }
160160

161161
void DumpDepthPacketProcessor::loadP0TablesFromCommandResponse(unsigned char* buffer, size_t buffer_length) {
162+
delete[] p0table_;
162163
p0table_ = new unsigned char[buffer_length];
163164
std::memcpy(p0table_, buffer, buffer_length);
164165
}
165166

166167
void DumpDepthPacketProcessor::loadXZTables(const float *xtable, const float *ztable) {
168+
delete[] xtable_;
167169
xtable_ = new float[TABLE_SIZE];
168170
std::memcpy(xtable_, xtable, TABLE_SIZE * sizeof(float));
169171

172+
delete[] ztable_;
170173
ztable_ = new float[TABLE_SIZE];
171174
std::memcpy(ztable_, ztable, TABLE_SIZE * sizeof(float));
172175
}
173176

174177
void DumpDepthPacketProcessor::loadLookupTable(const short *lut) {
178+
delete[] lut_;
175179
lut_ = new short[LUT_SIZE];
176180
std::memcpy(lut_, lut, LUT_SIZE * sizeof(short));
177181
}

0 commit comments

Comments
 (0)