- fix some small memory leaks (valgrind).
CVS patchset: 6998 CVS date: 2003/12/23 06:25:04
This commit is contained in:
parent
945bc28d58
commit
db03eb6a92
|
@ -878,6 +878,7 @@ apprentice_compile(/*@unused@*/ const fmagic fm,
|
|||
static const uint32_t ar[] = {
|
||||
MAGICNO, VERSIONNO
|
||||
};
|
||||
int rc = -1; /* assume failure */
|
||||
|
||||
if (dbname == NULL)
|
||||
return -1;
|
||||
|
@ -885,30 +886,34 @@ apprentice_compile(/*@unused@*/ const fmagic fm,
|
|||
if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
|
||||
(void)fprintf(stderr, "%s: Cannot open `%s' (%s)\n",
|
||||
__progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (write(fd, ar, sizeof(ar)) != sizeof(ar)) {
|
||||
(void)fprintf(stderr, "%s: error writing `%s' (%s)\n",
|
||||
__progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (lseek(fd, sizeof(**magicp), SEEK_SET) != sizeof(**magicp)) {
|
||||
(void)fprintf(stderr, "%s: error seeking `%s' (%s)\n",
|
||||
__progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (write(fd, *magicp, sizeof(**magicp) * *nmagicp)
|
||||
!= sizeof(**magicp) * *nmagicp) {
|
||||
(void)fprintf(stderr, "%s: error writing `%s' (%s)\n",
|
||||
__progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
goto exit;
|
||||
}
|
||||
rc = 0;
|
||||
|
||||
(void)close(fd);
|
||||
return 0;
|
||||
exit:
|
||||
if (fd >= 0)
|
||||
(void)close(fd);
|
||||
free(dbname);
|
||||
return rc;
|
||||
}
|
||||
/*@=bounds@*/
|
||||
|
||||
|
@ -934,8 +939,10 @@ apprentice_map(/*@unused@*/ const fmagic fm,
|
|||
if (dbname == NULL)
|
||||
return -1;
|
||||
|
||||
if ((fd = open(dbname, O_RDONLY)) == -1)
|
||||
if ((fd = open(dbname, O_RDONLY)) == -1) {
|
||||
free(dbname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fstat(fd, &st) == -1) {
|
||||
(void)fprintf(stderr, "%s: Cannot stat `%s' (%s)\n",
|
||||
|
@ -987,9 +994,11 @@ apprentice_map(/*@unused@*/ const fmagic fm,
|
|||
(*magicp)++;
|
||||
if (needsbyteswap)
|
||||
byteswap(*magicp, *nmagicp);
|
||||
free(dbname);
|
||||
return 0;
|
||||
|
||||
errxit:
|
||||
free(dbname);
|
||||
if (fd != -1)
|
||||
(void)close(fd);
|
||||
/*@-branchstate@*/
|
||||
|
|
|
@ -974,7 +974,7 @@ fmagicSMatch(const fmagic fm)
|
|||
int cont_level = 0;
|
||||
int need_separator = 0;
|
||||
/*@only@*/
|
||||
static int32_t * tmpoff = NULL;
|
||||
static int32_t * tmpoff = NULL; /* XXX memory leak */
|
||||
static int tmpdelta = 64;
|
||||
static size_t tmplen = 0;
|
||||
int32_t oldoff = 0;
|
||||
|
|
|
@ -808,12 +808,8 @@ static int filenamesTag(Header h, /*@out@*/ rpmTagType * type,
|
|||
/\ maxSet(count) >= 0 /\ maxSet(freeData) >= 0 @*/
|
||||
{
|
||||
*type = RPM_STRING_ARRAY_TYPE;
|
||||
|
||||
rpmfiBuildFNames(h, RPMTAG_BASENAMES, (const char ***) data, count);
|
||||
*freeData = 1;
|
||||
|
||||
*freeData = 0; /* XXX WTFO? */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1450,6 +1450,7 @@ if (fi->actions == NULL)
|
|||
(void) freecon(scon);
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
fi->fn = _free(fi->fn);
|
||||
|
||||
/* Initialize array ptrs into data following array. */
|
||||
len = ((fi->fc+1) * sizeof(*fi->fcontexts)) + fctxtlen;
|
||||
|
|
|
@ -747,7 +747,7 @@ int rpmAddSignature(Header sig, const char * file, int_32 sigTag,
|
|||
break;
|
||||
case RPMSIGTAG_MD5:
|
||||
pktlen = 16;
|
||||
pkt = xcalloc(1, pktlen);
|
||||
pkt = memset(alloca(pktlen), 0, pktlen);
|
||||
if (domd5(file, pkt, 0, NULL)
|
||||
|| !headerAddEntry(sig, sigTag, RPM_BIN_TYPE, pkt, pktlen))
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue