summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-09-27 14:22:56 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-09-27 14:55:12 +0300
commitd8777387db3128ea5f4f5b211d2aa54736f7f717 (patch)
treedc43cb3077ec5fd3869c63f909dead9896999aeb
parent49f99b86566bf71e1ebd8be4da29953aaf042b79 (diff)
downloadrpm-d8777387db3128ea5f4f5b211d2aa54736f7f717.tar.gz
rpm-d8777387db3128ea5f4f5b211d2aa54736f7f717.tar.bz2
rpm-d8777387db3128ea5f4f5b211d2aa54736f7f717.zip
Simplify / sanitize expandU() a bit
- Instead of saving and restoring the bits we'll mess with, just make a temporary expansion state struct with non-buffer state copied from "parent".
-rw-r--r--rpmio/macro.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/rpmio/macro.c b/rpmio/macro.c
index 1c94b3dc6..b8a9d5748 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -444,23 +444,18 @@ expandT(MacroBuf mb, const char * f, size_t flen)
static int
expandU(MacroBuf mb, char * u, size_t ulen)
{
- size_t tpos = mb->tpos;
- size_t nb = mb->nb;
- char *tbuf = mb->buf;
+ struct MacroBuf_s umb;
int rc;
- /* Force new expansion buffer */
- mb->buf = NULL;
- rc = expandMacro(mb, u);
+ /* Copy other state from "parent", but we want a buffer of our own */
+ umb = *mb;
+ umb.buf = NULL;
+ rc = expandMacro(&umb, u);
/* Copy back result, flag error on truncation */
- rc += (rstrlcpy(u, mb->buf, ulen) >= ulen);
+ rc += (rstrlcpy(u, umb.buf, ulen) >= ulen);
- _free(mb->buf);
-
- mb->buf = tbuf;
- mb->tpos = tpos;
- mb->nb = nb;
+ _free(umb.buf);
return rc;
}