Subject: | SEGV in rpmhdr_FETCH |
Hello,
$ perl -MRPM::Header -e '$h = RPM::Header->new; print $_=$$h{NAME}=1'
zsh: segmentation fault perl -MRPM::Header -e '$h = RPM::Header->new; print $_=$$h{NAME}=1'
$
--- RPM/Header.xs- 2005-09-06 23:23:51 +0000
+++ RPM/Header.xs 2005-09-06 23:39:03 +0000
@@ -372,11 +372,11 @@ SV* rpmhdr_FETCH(pTHX_ RPM__Header self,
sv_free(FETCH);
/* Check the three keys that are cached directly on the struct itself: */
- if (! strcmp(uc_name, "NAME"))
+ if (! strcmp(uc_name, "NAME") && hdr->name)
FETCH = newSVpv((char *)hdr->name, 0);
- else if (! strcmp(uc_name, "VERSION"))
+ else if (! strcmp(uc_name, "VERSION") && hdr->version)
FETCH = newSVpv((char *)hdr->version, 0);
- else if (! strcmp(uc_name, "RELEASE"))
+ else if (! strcmp(uc_name, "RELEASE") && hdr->release)
FETCH = newSVpv((char *)hdr->release, 0);
else
{
End of patch
$ perl -Mblib -MRPM::Header -e '$h = RPM::Header->new; print $_=$$h{NAME}=1'
1
$
"Premature optimization is the root of all evil".
--
Alexey Tourbin
ALT Linux Team