[augeas-devel] [PATCH] check for a few failed memory allocations
David Lutterkort
dlutter at redhat.com
Mon Apr 28 18:12:14 UTC 2008
On Mon, 2008-04-28 at 19:55 +0200, Jim Meyering wrote:
> There are may more, but you have to start somewhere...
>
> * src/augtool.c: check for a few failed memory allocations
ACK .. thanks for doing that.
> @@ -392,7 +395,10 @@
> current += 1;
> if (STREQLEN(child, text, strlen(text))) {
> if (child_count(child) > 0) {
> - child = realloc(child, strlen(child)+2);
> + char *c = realloc(child, strlen(child)+2);
> + if (c == NULL)
> + return NULL;
> + child = c;
Out of curiosity (and for my education): why the additional var 'c' ? I
understand why you'd do that if you needed to free child after a failed
allocation, but in this case that's not necessary.
David
More information about the augeas-devel
mailing list