[asterisk-dev] [svn-commits] tilghman: branch tilghman/res_odbc_astobj2 r101392 - /team/tilghman/res_odbc_...
Kevin P. Fleming
kpfleming at digium.com
Fri Feb 1 09:10:32 CST 2008
Russell Bryant wrote:
> You missed unreferencing 'class' in that big while loop. You can just
> change the while to something like:
>
> for (class = ao2_iterator_next(&aoi); class = ao2_iterator_next(&aoi);
> ao2_ref(class, -1)) {
Maybe I'm misunderstanding, but this for loop looks wrong to me.
On the first iteration, 'class' will be set to the first object in
iterator. All is good.
At the end of that iteration, the for loop will set 'class' to the next
object in the iterator; if there isn't one, the loop will exit, and the
previous object reference will never be released.
If on the other hand the next object was found, then the reference to
*it* (not the previous object) will immediately be released, and then
the loop will be entered, using a pointer to an object without holding a
reference to it.
Am I misreading this?
--
Kevin P. Fleming
Director of Software Technologies
Digium, Inc. - "The Genuine Asterisk Experience" (TM)
More information about the asterisk-dev
mailing list