In gdImageScaleTwoPass() a tmp_im is created with gdImageCreateTrueColor(), but later freed with gdFree() instead of gdImageDestroy(). This is likely to cause a memory leak.
See also the related downstream bug report.
gdImageScaleTwoPass memory leak fix
Fixing memory leak in gdImageScaleTwoPass, as reported by @cmb69 and
confirmed by @vapier. This bug actually bit me in production and I'm
very thankful that it was reported with an easy fix.
Issue was assigned CVE-2015-8877. Details at https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-8877
@kaplanlior Thanks! That info is yet missing in the changelog of PHP 5.6.12 and 7.0.0.