[XML-SIG] Bug in exception handling?

Rob Hooft r.hooft@euromail.net
Thu, 8 Jul 1999 11:05:11 +0200 (MZT)


 > Sounds like a hack to me. Shouldn't it be solved by INCREF'ing the buffer
 > somewhere in the C code to pyexpat? e.g. where the exception code makes
 > reference to the buffer? I didn't look at the code myself, so I don't
 > know whether it is particularly difficult to find.

 JJ> I looked, but I can't see anything. I haven't a clue how this code code be 
 JJ> responsible for an extra free:

   [...]
 JJ> if (setjmp(self->jmpbuf)) {
 JJ> /* Error in callback routine */
 JJ> return NULL;
 JJ> }
   [...]

<SPECULATION>
But, at this return NULL (i.e. if something went wrong during
parsing?)  the last reference to "s" disappears, and hence it is
garbage collected. Apparently, when the code later tries to find
out line number and column of the error, it tries to refer to the
same s again, which fails. So either "s" must be INCREF()d before
the return NULL, or the error coordinates must be precalculated
right there.
</SPECULATION>

-- 
=====   R.Hooft@EuroMail.net   http://www.xs4all.nl/~hooft/rob/  =====
=====   R&D, Nonius BV, Delft  http://www.nonius.nl/             =====
===== PGPid 0xFA19277D ========================== Use Linux! =========