diff options
author | rjray <devnull@localhost> | 2000-08-25 15:21:11 +0000 |
---|---|---|
committer | rjray <devnull@localhost> | 2000-08-25 15:21:11 +0000 |
commit | 1834248adbd92628b84e3cc9954b514f11c7dab7 (patch) | |
tree | ab2ff832426e452d43232a1fe144f777d7a7ce11 /Perl-RPM | |
parent | ca22ac99c14be4b531f369889ba1708233c4f666 (diff) | |
download | rpm-1834248adbd92628b84e3cc9954b514f11c7dab7.tar.gz rpm-1834248adbd92628b84e3cc9954b514f11c7dab7.tar.bz2 rpm-1834248adbd92628b84e3cc9954b514f11c7dab7.zip |
fixes to rpmhdr_STORE
CVS patchset: 4127
CVS date: 2000/08/25 15:21:11
Diffstat (limited to 'Perl-RPM')
-rw-r--r-- | Perl-RPM/RPM/Header.xs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Perl-RPM/RPM/Header.xs b/Perl-RPM/RPM/Header.xs index c01157b21..4f510901d 100644 --- a/Perl-RPM/RPM/Header.xs +++ b/Perl-RPM/RPM/Header.xs @@ -4,7 +4,7 @@ #include "RPM.h" -static char * const rcsid = "$Id: Header.xs,v 1.15 2000/08/18 08:25:39 rjray Exp $"; +static char * const rcsid = "$Id: Header.xs,v 1.16 2000/08/25 15:21:11 rjray Exp $"; static int scalar_tag(pTHX_ SV *, int); /* @@ -680,15 +680,20 @@ int rpmhdr_STORE(pTHX_ RPM__Header self, SV* key, SV* value) char** data_p; char* str_sv; char* str_new; + SV* cloned; STRLEN len; if (data_type == RPM_STRING_TYPE && size == 1) { /* Special case for exactly one RPM_STRING_TYPE */ svp = av_fetch(a_value, 0, FALSE); - if (svp && SvPOK(*svp)) + if (svp) { - str_sv = SvPV(*svp, len); + if (SvPOK(*svp)) + cloned = *svp; + else + cloned = sv_mortalcopy(*svp); + str_sv = SvPV(cloned, len); str_new = safemalloc(len + 1); strncpy(str_new, str_sv, len + 1); } @@ -704,8 +709,12 @@ int rpmhdr_STORE(pTHX_ RPM__Header self, SV* key, SV* value) for (i = 0; i < size; i++) { svp = av_fetch(a_value, i, FALSE); - if (svp && SvPOK(*svp)) + if (svp) { + if (SvPOK(*svp)) + cloned = *svp; + else + cloned = sv_mortalcopy(*svp); str_sv = SvPV(*svp, len); str_new = safemalloc(len + 1); strncpy(str_new, str_sv, len + 1); |