summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-29 12:59:20 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-29 12:59:20 +0300
commit69e3540ed0c875221147d9af5ab90089d55e5fa5 (patch)
tree20dd737bafcc5e6d937b2d717cae9067309d5b16
parent226c4d16279702593ff814b1573e79e33e17fd72 (diff)
downloadrpm-69e3540ed0c875221147d9af5ab90089d55e5fa5.tar.gz
rpm-69e3540ed0c875221147d9af5ab90089d55e5fa5.tar.bz2
rpm-69e3540ed0c875221147d9af5ab90089d55e5fa5.zip
Avoid alloca() in shescapeFormat()
-rw-r--r--rpmdb/header.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/rpmdb/header.c b/rpmdb/header.c
index 53f2b362a..13202a86e 100644
--- a/rpmdb/header.c
+++ b/rpmdb/header.c
@@ -2962,16 +2962,16 @@ static char * dayFormat(rpmTagType type, rpm_constdata_t data,
static char * shescapeFormat(rpmTagType type, rpm_constdata_t data,
char * formatPrefix, size_t padding,int element)
{
- char * result, * dst, * src, * buf;
+ char * result, * dst, * src;
if (type == RPM_INT32_TYPE) {
result = xmalloc(padding + 20);
strcat(formatPrefix, "d");
sprintf(result, formatPrefix, *((const int32_t *) data));
} else {
- buf = alloca(strlen(data) + padding + 2);
+ char *buf = NULL;
strcat(formatPrefix, "s");
- sprintf(buf, formatPrefix, data);
+ rasprintf(&buf, formatPrefix, data);
result = dst = xmalloc(strlen(buf) * 4 + 3);
*dst++ = '\'';
@@ -2987,7 +2987,7 @@ static char * shescapeFormat(rpmTagType type, rpm_constdata_t data,
}
*dst++ = '\'';
*dst = '\0';
-
+ free(buf);
}
return result;