Commit graph

12 commits

Author SHA1 Message Date
YAMAMOTO Takashi
f1dd37fbdb quirc_resize: Make this a bit more careful about integer overflows
Also, avoid malloc(0), which is not too portable.
2021-05-11 11:05:58 +09:00
YAMAMOTO Takashi
772cd3e73f Improve stack usage for flood filling
* Make flood filling logic iterative (vs recursive)
  I basically tried one-to-one conversions here to avoid mistakes.
  probably it has a room for later optimizations.

* Use explicit malloc (vs variables on stack) to allocate the work area.

* Estimate the amount of memory for the work area dynamically
  from the image size, instead of using a constant FLOOD_FILL_MAX_DEPTH,
  which is too big in the most cases.
2021-05-11 11:05:58 +09:00
Alexandre Perrin
f700e456b4 define a QUIRC_PIXEL_ALIAS_IMAGE constant to explicit conditional path
Before this patch, the "sizeof dance" was confusing, fix #54.
2019-07-02 09:22:25 +02:00
Claudio Felber
96a5a380fb Remove quirc.row_average and associated code
quirc.row_average was used by the former threshold function and has
become obsolete with the introduction of the Otsu threshold function.
2019-04-30 18:43:57 +02:00
Alexandre Perrin
d3780f3e6f Warning comment improvement. 2017-06-11 10:19:31 +02:00
Alexandre Perrin
21f6863577 Added a row_average member to struct quirc.
Prep to remove the VLA from threshold()
2017-06-11 10:08:58 +02:00
Alexandre Perrin
971c9d4e8c refactor quirc_resize
So that the given quirc struct is never invalid once we return to the
caller.
2017-06-09 22:12:06 +02:00
Alexandre Perrin
1f9edb0b84 Fix a potential use-after-free on quirc_resize failure.
Before this patch, in the event of `q->image` reallocation success but
`q->pixels` failure, `q->image` would point to a freed memory.

After this patch, once quirc_resize() returns, `q->image` consistently
point to a memory address that can be freed.

There is still an inconsistency left in the example codepath: `q->{h,w}`
would hold the "old" values, while `q->image` allocated size would be
based in the requested width/height; hence the comment update about the
state of the QR-code recognizer (it should only be passed to
quirc_destroy()).
2017-06-07 19:37:14 +02:00
Daniel Beer
3c31aa0987 Fix potential leak on allocation failure in quirc_resize(). 2017-05-18 19:29:02 +12:00
Alexandre Perrin
3a6efb3d84 Large images decoding support
Fix #2, this patch makes large images support a compile time option by
allowing QUIRC_MAX_REGIONS to be tuned via CFLAGS up to 65534 (current
default is 254).
2016-07-15 14:40:40 +02:00
Daniel Beer
c8b1861b8f quirc_strerror: fix off by one error.
Bug reported by Harald Eilertsen (http://github.com/snake66/).
2013-02-02 18:04:49 +13:00
Daniel Beer
a3142bc6b4 Initial commit: version 1.0. 2012-05-04 12:58:42 +12:00