Commit 7f72a007 authored by Bernhard Link's avatar Bernhard Link

fix some minor memory/resource leaks found by cppcheck

parent 547930fb
2010-12-23
* fix some minor memory/resource leaks found by cppcheck
2010-10-16
* support "ButAutomaticUpgrades" field to be copied to
the generated Release files (Thanks to Modestas Vainius)
......
......@@ -76,12 +76,14 @@ retvalue byhandhooks_parse(struct configiterator *iter, struct byhandhook **hook
if( r == RET_NOTHING )
continue;
if( RET_WAS_ERROR(r) )
return r;
break;
h = calloc(1, sizeof(struct byhandhook));
if( FAILEDTOALLOC(h) ) {
byhandhooks_free(hooks);
return RET_ERROR_OOM;
r = RET_ERROR_OOM;
break;
}
*nexthook_p = h;
nexthook_p = &h->next;
h->sectionglob = v;
r = config_getwordinline(iter, &v);
if( r == RET_NOTHING ) {
......@@ -91,10 +93,8 @@ retvalue byhandhooks_parse(struct configiterator *iter, struct byhandhook **hook
config_markercolumn(iter));
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
byhandhooks_free(hooks);
return r;
}
if( RET_WAS_ERROR(r) )
break;
h->priorityglob = v;
r = config_getwordinline(iter, &v);
if( r == RET_NOTHING ) {
......@@ -104,10 +104,8 @@ retvalue byhandhooks_parse(struct configiterator *iter, struct byhandhook **hook
config_markercolumn(iter));
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
byhandhooks_free(hooks);
return r;
}
if( RET_WAS_ERROR(r) )
break;
h->filenameglob = v;
r = config_getwordinline(iter, &v);
if( r == RET_NOTHING ) {
......@@ -117,17 +115,15 @@ retvalue byhandhooks_parse(struct configiterator *iter, struct byhandhook **hook
config_markercolumn(iter));
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
byhandhooks_free(hooks);
return r;
}
if( RET_WAS_ERROR(r) )
break;
assert( v != NULL && v[0] != '\0' ); \
if( v[0] != '/' ) {
h->script = calc_dirconcat(global.confdir, v);
free(v);
if( h->script == NULL ) {
byhandhooks_free(hooks);
return RET_ERROR_OOM;
r = RET_ERROR_OOM;
break;
}
} else
h->script = v;
......@@ -140,12 +136,12 @@ retvalue byhandhooks_parse(struct configiterator *iter, struct byhandhook **hook
free(v);
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
byhandhooks_free(hooks);
return r;
}
*nexthook_p = h;
nexthook_p = &h->next;
if( RET_WAS_ERROR(r) )
break;
}
if( RET_WAS_ERROR(r) ) {
byhandhooks_free(hooks);
return r;
}
*hooks_p = hooks;
return RET_OK;
......
......@@ -204,6 +204,7 @@ static retvalue pull_initdistribution(struct pull_distribution **pp,
fprintf(stderr,
"Error: Unknown pull rule '%s' in distribution '%s'!\n",
name, distribution->codename);
free(p);
return RET_ERROR_MISSING;
}
p->rules[i] = rule;
......
......@@ -129,6 +129,8 @@ static retvalue gen_sha1sum(const char *fullfilename, /*@out@*/struct hash *hash
e = errno;
fprintf(stderr,"Error %d getting information about '%s': %s\n",
e, fullfilename, strerror(e));
(void)close(infd);
free(buffer);
return RET_ERRNO(e);
}
do {
......
......@@ -260,6 +260,7 @@ static retvalue signature_sign(const char *options, const char *filename, void *
e, signaturename,
strerror(e));
free(signature_data);
(void)close(fd);
return RET_ERRNO(e);
}
signature_len -= written;
......
......@@ -512,6 +512,7 @@ static retvalue parse_changes_files(struct changes *c, struct strlist filelines[
p++;
if( *p != '\0' ) {
fprintf(stderr,"Unexpected sixth argument in '%s'!\n", tmp->values[i]);
free(hashes);
return RET_ERROR;
}
if( fileend - filestart == 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment