FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 11-24-2007, 10:02 AM
Xavier
 
Default Fix several memleaks, mostly related to errors handling.

On Fri, Nov 23, 2007 at 11:51:01PM -0500, Dan McGee wrote:
> This looks good, but take a look at my one thought below in the patch.
>
> On Nov 23, 2007 6:19 PM, Chantry Xavier <shiningxc@gmail.com> wrote:
> > @@ -614,42 +615,35 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
> > if(errorout) {
> > + /* The last conflict was unresolvable, so we duplicate it and add it to *data */
> > pm_errno = PM_ERR_CONFLICTING_DEPS;
> > + if(data) {
> > + pmconflict_t *lastconflict = conflict;
> > + if((conflict = malloc(sizeof(pmconflict_t))) == NULL) {
> > + _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %zd bytes
"),
> > + sizeof(pmconflict_t));
> > + FREELIST(*data);
> > + pm_errno = PM_ERR_MEMORY;
> Can the above be replaced by a call to MALLOC?

That's the first thing I thought about, but I don't know if that is possible.
There are two lists that can only be freed after the error happens : *data
and deps (asked could be freed before).
Or maybe it is possible to do something like :
MALLOC(miss, sizeof(pmdepmissing_t), FREELIST(*data); FREELIST(deps);
RET_ERR(PM_ERR_MEMORY, -1));

Though, there is also the "goto cleanup;" that would be skipped, and so the
"alpm_list_free(list);", so that's yet another call to add there.
So that would duplicate the "FREELIST(deps)'" and "alpm_list_free(list);"
calls.

>
> > + } else {
> > + *conflict = *lastconflict;
> > + *data = alpm_list_add(*data, conflict);
> > + }
> > + }
> > + FREELIST(asked);
> > + FREELIST(deps);
> > ret = -1;
> > goto cleanup;
> > }
> > - FREELIST(deps);
> > FREELIST(asked);
> > + FREELIST(deps);
> > }
> > EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
> > }

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 02:06 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org