Subject: | DBD-Oracle crashes when trying to read empty LOB |
Date: | Thu, 22 Nov 2007 08:25:52 +0100 |
To: | bug-DBD-Oracle [...] rt.cpan.org |
From: | "Boleslav Bobcik" <bbobcik [...] gmail.com> |
Module: DBD::Oracle (version 1.19 and lower)
OS: WinXP
Interpreter: ActiveState Perl 5.8.8
Symptoms:
When trying to retrieve LOB data, where length of LOB is 0,
ora_lob_read() crashes the interpreter with invalid memory access.
Cause:
Looking at the debugged code, I think that the problem is at the line
312 of Oracle.xs:
dest_sv = sv_2mortal(newSV(length*4)); /*LAB: crude hack that
works... tim did it else where XXX */
Apparently, when length==0, the resulting dest_sv is NULL and
subseqent access to it is invalid. I haven't an access to different
platform than Windows, therefore I am unable to verify this behaviour
in other environments.
It is possible to use the following workaround, but in my opinion it's
just a case of "ugly hacks escalation":
$lob_size = $dbh->ora_lob_length($lob_locator);
$lob = $dbh->ora_lob_read($lob_locator, 1, $lob_size+1);
However I believe that the problem should be quite easy to fix (e.g.
early return when length is zero).
--Boleslav Bobcik
bbobcik@gmail.com