Merged to the staging branch. On 5/6/15 12:07 AM, Maninder Singh wrote: > EP-F6AA0618C49C4AEDA73BFF1B39950BAB > > Hi Mark, > > Free previously allocated memory if realloc fails. > > Signed-off-by: Maninder Singh <maninder...@samsung.com> > Signed-off-by: Vaneet narang <v.nar...@samsung.com> > Reviewed-by: Akhilesh Kumar <akhiles...@samsung.com> > --- > trunk/src/doit.c | 4 +++- > trunk/src/gather.c | 4 +++- > trunk/src/undoall.c | 4 +++- > 3 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/trunk/src/doit.c b/trunk/src/doit.c > index c94fc53..0995fce 100644 > --- a/trunk/src/doit.c > +++ b/trunk/src/doit.c > @@ -53,7 +53,7 @@ prelink_ent (struct prelink_entry *ent) > DSO *dso; > struct stat64 st; > struct prelink_link *hardlink; > - char *move = NULL; > + char *move = NULL, *move_temp; > size_t movelen = 0; > > for (i = 0; i < ent->ndepends; ++i) > @@ -176,9 +176,11 @@ prelink_ent (struct prelink_entry *ent) > if (len + sizeof (".#prelink#") > movelen) > { > movelen = len + sizeof (".#prelink#"); > + move_temp = move; > move = realloc (move, movelen); > if (move == NULL) > { > + free(move_temp); > error (0, ENOMEM, "Could not hardlink %s to %s", > hardlink->canon_filename, ent->canon_filename); > movelen = 0; > diff --git a/trunk/src/gather.c b/trunk/src/gather.c > index c3d3128..733b49f 100644 > --- a/trunk/src/gather.c > +++ b/trunk/src/gather.c > @@ -64,7 +64,7 @@ gather_deps (DSO *dso, struct prelink_entry *ent) > const char *argv[6]; > const char *envp[5]; > char *line = NULL, *p, *q = NULL; > - const char **depends = NULL; > + const char **depends = NULL, **depends_temp; > size_t ndepends = 0, ndepends_alloced = 0; > size_t len = 0; > ssize_t n; > @@ -261,11 +261,13 @@ gather_deps (DSO *dso, struct prelink_entry *ent) > if (ndepends == ndepends_alloced) > { > ndepends_alloced += 10; > + depends_temp = depends; > depends = > (const char **) realloc (depends, > ndepends_alloced * sizeof (char *)); > if (depends == NULL) > { > + free(depends_temp); > error (0, ENOMEM, "%s: Could not record dependencies", > ent->filename); > goto error_out; > diff --git a/trunk/src/undoall.c b/trunk/src/undoall.c > index 90e9240..6163da3 100644 > --- a/trunk/src/undoall.c > +++ b/trunk/src/undoall.c > @@ -33,7 +33,7 @@ undo_one (void **p, void *info) > DSO *dso; > struct stat64 st; > struct prelink_link *hardlink; > - char *move = NULL; > + char *move = NULL, *move_temp; > size_t movelen = 0; > > if (ent->done != 2) > @@ -116,9 +116,11 @@ undo_one (void **p, void *info) > if (len + sizeof (".#prelink#") > movelen) > { > movelen = len + sizeof (".#prelink#"); > + move_temp = move; > move = realloc (move, movelen); > if (move == NULL) > { > + free(move_temp); > error (0, ENOMEM, "Could not hardlink %s to %s", > hardlink->canon_filename, ent->canon_filename); > movelen = 0; >
-- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto