If realloc fails it returns NULL and out pointer becomes invalid. To
fix this it is necessary to store realloc return value in temporary
pointer and then compare it with NULL. If it equals NULL then return
error and source pointer will still valid.
This error was caught by cppcheck:
Common realloc mistake: 'out' nulled but not freed upon failure.
The fucntions are:
stbtt_GetCodepointSVG - provides a pointer to the SVG data in the supplied argument, and returns the length of this data
stbtt_GetGlyphSVG - As above but takes the glyph index instead of the codepoint
Note that the returned data may be deflate compressed.
When calling stbtt_PackFontRanges, multiple missing glyphs in the range
of codepoints will create multiple copies of the font's missing glyph to
be added to the pixel buffer. Instead, the first codepoint that maps to the missing glyph will add it to the pixel buffer, and all subsequent glyphs will simply copy the stbtt_packedchar data to reference the same region of the buffer.
This does NOT prevent duplication in multiple calls to stbtt_PackFontRange(s) - that would require modifying the packing context, which could be nice but is a bit more intrusive.
- arena and strdup string hashes were badly broken due to not setting up default slot correctly
- tweak use of seed in 4-byte and 8-byte hash functions to hopefully be slightly stronger
- a few internal #ifdefs for performance tuning
I must've missed it when I did this for the other image loaders.
Either way, combined with the previous checkin, this should fix
issue #614 properly.
Fixes issue #614.
1. Check not just g->out allocation for failure.
2. If an image descriptor specified a 0-width image, this could be
used to produce an out-of-bounds write.
3. Fix memory leak in case an error occurs during decoding.
Fixes issue #656.
stbrp__skyline_find_best_pos didn't correctly handle rects too
large to ever fit inside the context. Since that function also
pads the width up to a multiple of the alignment, it makes the
most sense to do that check right after (but before entering
the main packing loop).
While we're here, also fix an off-by-1 bug in the best-fit
heuristic where it didn't want to use the last row in
certain cases.
Fixes issue #701.