diff options
author | nanardon <nanardon@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2007-07-03 23:27:51 +0000 |
---|---|---|
committer | nanardon <nanardon@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2007-07-03 23:27:51 +0000 |
commit | 6a874bd8da2dc4309c2ab217542d4abcefc90ab9 (patch) | |
tree | d0b536e7e06071efbeda236674965ed4daf2dd56 /RPM4 | |
parent | 59079f6165c70e012e692c09ca8ec29c1f24b288 (diff) | |
download | perl-RPM4-6a874bd8da2dc4309c2ab217542d4abcefc90ab9.tar perl-RPM4-6a874bd8da2dc4309c2ab217542d4abcefc90ab9.tar.gz perl-RPM4-6a874bd8da2dc4309c2ab217542d4abcefc90ab9.tar.bz2 perl-RPM4-6a874bd8da2dc4309c2ab217542d4abcefc90ab9.tar.xz perl-RPM4-6a874bd8da2dc4309c2ab217542d4abcefc90ab9.zip |
- fix 2 memleaks
git-svn-id: svn+ssh://haiku.zarb.org/home/projects/rpm4/svn/trunk@130 971eb68f-4bfb-0310-8326-d2484c010a4c
Diffstat (limited to 'RPM4')
-rw-r--r-- | RPM4/src/RPM4.xs | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/RPM4/src/RPM4.xs b/RPM4/src/RPM4.xs index ca5a672..e0137fb 100644 --- a/RPM4/src/RPM4.xs +++ b/RPM4/src/RPM4.xs @@ -994,21 +994,15 @@ Header_string(h, no_header_magic = 0) int no_header_magic PREINIT: char * string = NULL; - int offset = 0; + int offset = 8; /* header magic length */ void * ptr = NULL; int hsize = 0; PPCODE: - ptr = headerUnload(h); - hsize = headerSizeof(h, no_header_magic ? HEADER_MAGIC_NO : HEADER_MAGIC_YES); - string = malloc(hsize); - if (!no_header_magic) { - memcpy(string, header_magic, sizeof(header_magic)); - offset = sizeof(header_magic); - } - memcpy(string + offset, ptr, headerSizeof(h, HEADER_MAGIC_NO)); - PUSHs(sv_2mortal(newSVpv((char *)string, hsize))); - free(ptr); - + string = headerUnload(h); + hsize = headerSizeof((Header) string, no_header_magic ? HEADER_MAGIC_NO : HEADER_MAGIC_YES); + ptr = string + (no_header_magic ? offset : 0); + PUSHs(sv_2mortal(newSVpv((char *)ptr, hsize))); + free(string); int Header_removetag(h, sv_tag) @@ -1204,14 +1198,7 @@ Header_queryformat(h, query) PPCODE: s = headerSprintf(h, query, rpmTagTable, rpmHeaderFormats, NULL); - if (s) { - char * cs = NULL; - int len = strlen(s); - - cs = malloc(strlen(s)); /* TODO need to check return of malloc */ - memcpy(cs, s, len); - XPUSHs(sv_2mortal(newSVpv(cs, len))); - } + XPUSHs(sv_2mortal(newSVpv(s, 0))); _free(s); void |