Hi,
First, thank you for all your work in making this library!
I am using ZBar in my code and I found a bug in PointIterator in symbol.h and a possible fix. I wanted to share it.
When you construct a PointIterator with Symbol *sym = NULL, a memory access violation is occurred when you try to set the reference with "sym->ref(1);"
The same problem occurs in the destructor when you do "_sym->ref(-1);"
The solution is to not set reference if _sym is NULL:
/// constructor.
PointIterator (const Symbol *sym = NULL,
int index = 0)
: _sym(sym),
_index(index)
{
if(!sym ||
(unsigned)_index >= zbar_symbol_get_loc_size(*_sym))
_index = -1;
else
_sym->ref(1);
}
/// destructor.
~PointIterator ()
{
if (_sym)
_sym->ref(-1);
}
I actually ran into this bug with this code:
for (Symbol::PointIterator p(symbol->point_begin()); p != symbol->point_end(); ++p)
The point_end() caused a PointIterator() to be constructed with sym as NULL, causing this problem.
Is my solution okay? If so, I am :) that I could actually debug something in such a big library.
Thanks!
This is the windows port by the way!
Great job, thanks for reporting this!
Should be fixed now in hg (rev 7dfcfb9f5e6b), along with beefed up testing.
fwiw, the complete fix was more involved, but you had the basic idea.