Skip to content

Commit

Permalink
fixed memory leak when reading cube data points
Browse files Browse the repository at this point in the history
  • Loading branch information
michelerenzullo authored Oct 13, 2021
1 parent 139a018 commit b7cd453
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions XMPConverter/XMPconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ void encode(string path, string& outFileName) {
printf("- test encoding back -\nTITLE: %s\nSIZE: %d\n", options.title.c_str(), input_size);
double* samples_1 = new double[input_size * input_size * input_size * 3];

char* points = nullptr;
for (const char* s = text->c_str(); *s;) if (*s++ == '\n' && *s <= '9' && *s >= '0') { points = _strdup(s); delete text; break; }
char* points = nullptr; char* points_address = nullptr;
for (const char* s = text->c_str(); *s;) if (*s++ == '\n' && *s <= '9' && *s >= '0') { points = points_address = _strdup(s); delete text; break; }

This comment has been minimized.

Copy link
@michelerenzullo

michelerenzullo Oct 14, 2021

Author Owner

we have to store the original position of the pointer, so we can free later and avoid memory leak

for (int32 idx = 0; idx < input_size * input_size * input_size * 3;) samples_1[idx++] = strtod(points++, &points);
free(points_address);

uint32 size = (input_size > options.size) ? options.size : input_size;
if (input_size > 32) printf("ACR unsupports LUT>32, resampling enabled\n");
Expand Down

0 comments on commit b7cd453

Please sign in to comment.