good for merge regards -steve
On Mon, 2009-04-20 at 18:53 +0200, Jim Meyering wrote: > This fixes the last of the unchecked-strdup problems: > > From 143bf3681c180c0dd8c14596fde240808827615a Mon Sep 17 00:00:00 2001 > From: Jim Meyering <[email protected]> > Date: Mon, 20 Apr 2009 18:51:46 +0200 > Subject: [PATCH] corosync-cfgtool.c: handle strdup failure gracefully > > * tools/corosync-cfgtool.c (xstrdup): New function. > (main): Use it in place of strdup. > --- > tools/corosync-cfgtool.c | 15 +++++++++++++-- > 1 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/tools/corosync-cfgtool.c b/tools/corosync-cfgtool.c > index da02619..52e4f93 100644 > --- a/tools/corosync-cfgtool.c > +++ b/tools/corosync-cfgtool.c > @@ -245,6 +245,17 @@ static void usage_do (void) > printf ("\t-H\tShutdown corosync cleanly on this node.\n"); > } > > +static char * > +xstrdup (char const *s) > +{ > + char *p = strdup (s); > + if (p) > + return (char *) p; > + > + printf ("exhausted virtual memory\n"); > + exit (1); > +} > + > int main (int argc, char *argv[]) { > const char *options = "srl:u:v:k:a:hH"; > int opt; > @@ -267,11 +278,11 @@ int main (int argc, char *argv[]) { > break; > case 'l': > service_load = 1; > - service = strdup (optarg); > + service = xstrdup (optarg); > break; > case 'u': > service_unload = 1; > - service = strdup (optarg); > + service = xstrdup (optarg); > break; > case 'k': > nodeid = atoi (optarg); > -- > 1.6.3.rc0.230.g3edd6 > _______________________________________________ > Openais mailing list > [email protected] > https://lists.linux-foundation.org/mailman/listinfo/openais _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
