mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-08-15 11:31:15 +00:00
corosync-cfgtool.c: handle strdup failure gracefully
* tools/corosync-cfgtool.c (xstrdup): New function. (main): Use it in place of strdup. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2100 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
cd154d63e6
commit
f5edd27d1d
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user