Skip to content
This repository

two possible memleaks in werkkzeug3 #13

Merged
merged 2 commits into from about 2 years ago

2 participants

Peter Hille (png!das-system) Fabian 'ryg' Giesen
Peter Hille (png!das-system)
png85 commented

hi,
the commits in this pull request fix two posible memory leaks in the Bitmap_Blur() functions of genbitmap.cpp and w3texlib/genbitmap.cpp
the problem with the original files was that 'qq' was initialized to heap memory but never freed before returning from the function when 'order' is 0.
to counter this i've moved the allocation of the pointer below the problematic 'if' statement which should be reasonably safe since it didn't get used before anyways.

Fabian 'ryg' Giesen rygorous merged commit 66f3243 into from
Fabian 'ryg' Giesen rygorous closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
5 werkkzeug3/genbitmap.cpp
@@ -1463,11 +1463,12 @@ GenBitmap * __stdcall Bitmap_Blur(GenBitmap *bm,sInt flags,sF32 sx,sF32 sy,sF32
1463 1463
1464 1464 // prepare
1465 1465
1466   - pp = (sU16 *)bm->Data;
1467   - qq = (sU16 *) new sU64[bm->Size];
1468 1466 order = flags & 15;
1469 1467 if(order==0) return bm;
1470 1468
  1469 + pp = (sU16 *)bm->Data;
  1470 + qq = (sU16 *) new sU64[bm->Size];
  1471 +
1471 1472 // blur x
1472 1473
1473 1474 size = sFtol(128*sx*bm->XSize);
5 werkkzeug3/w3texlib/genbitmap.cpp
@@ -1346,11 +1346,12 @@ GenBitmap * __stdcall Bitmap_Blur(GenBitmap *bm,sInt flags,sF32 sx,sF32 sy,sF32
1346 1346
1347 1347 // prepare
1348 1348
1349   - pp = (sU16 *)bm->Data;
1350   - qq = (sU16 *) new sU64[bm->Size];
1351 1349 order = flags & 15;
1352 1350 if(order==0) return bm;
1353 1351
  1352 + pp = (sU16 *)bm->Data;
  1353 + qq = (sU16 *) new sU64[bm->Size];
  1354 +
1354 1355 // blur x
1355 1356
1356 1357 size = sFtol(128*sx*bm->XSize);

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.