summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-10-21 12:22:33 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-10-21 12:22:33 +0300
commitb6cfb4399ca4c5f2335c9351a7599ccfdf28add6 (patch)
treea30658993b9f17a91cff44a32ae4fe34254de82b /build
parentcab7c23976fa83a57fcb63694748e0e40ca9fda4 (diff)
downloadrpm-b6cfb4399ca4c5f2335c9351a7599ccfdf28add6.tar.gz
rpm-b6cfb4399ca4c5f2335c9351a7599ccfdf28add6.tar.bz2
rpm-b6cfb4399ca4c5f2335c9351a7599ccfdf28add6.zip
Fix memory leaks on error exit from parseRCPOT()
Diffstat (limited to 'build')
-rw-r--r--build/parseReqs.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/build/parseReqs.c b/build/parseReqs.c
index 5c8627fa7..1a657a6d7 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -37,9 +37,10 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTag tagN,
int index, rpmsenseFlags tagflags)
{
const char *r, *re, *v, *ve;
- char * N, * EVR;
+ char * N = NULL, * EVR = NULL;
rpmsenseFlags Flags;
Header h;
+ rpmRC rc = RPMRC_FAIL; /* assume failure */
switch (tagN) {
case RPMTAG_PROVIDEFLAGS:
@@ -106,7 +107,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTag tagN,
rpmlog(RPMLOG_ERR,
_("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s\n"),
spec->lineNum, spec->line);
- return RPMRC_FAIL;
+ goto exit;
}
re = r;
@@ -133,7 +134,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTag tagN,
rpmlog(RPMLOG_ERR,
_("line %d: Versioned file name not permitted: %s\n"),
spec->lineNum, spec->line);
- return RPMRC_FAIL;
+ goto exit;
}
switch(tagN) {
@@ -163,21 +164,30 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTag tagN,
if (*v == '\0' || ve == v) {
rpmlog(RPMLOG_ERR, _("line %d: Version required: %s\n"),
spec->lineNum, spec->line);
- return RPMRC_FAIL;
+ goto exit;
}
EVR = xmalloc((ve-v) + 1);
rstrlcpy(EVR, v, (ve-v) + 1);
- if (rpmCharCheck(spec, EVR, ve-v, ".-_+:")) return RPMRC_FAIL;
+ if (rpmCharCheck(spec, EVR, ve-v, ".-_+:")) goto exit;
re = ve; /* ==> next token after EVR string starts here */
} else
EVR = NULL;
- (void) addReqProv(spec, h, tagN, N, EVR, Flags, index);
+ if (addReqProv(spec, h, tagN, N, EVR, Flags, index)) {
+ rpmlog(RPMLOG_ERR, _("line %d: invalid dependency: %s\n"),
+ spec->lineNum, spec->line);
+ goto exit;
+ }
N = _free(N);
EVR = _free(EVR);
}
+ rc = RPMRC_OK;
+
+exit:
+ free(N);
+ free(EVR);
- return RPMRC_OK;
+ return rc;
}