aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2018-01-03 00:32:14 +0100
committerUlrich Sibiller <uli42@gmx.de>2018-01-07 01:27:07 +0100
commitdc61b6ccacb0cd535e125f6e3831c5d0b3d073b4 (patch)
treedd295ab76e85ecf12d9798ec5bd8f9f80c412296
parent96e430069b24e0a4cd53e47e38786802999d31f4 (diff)
downloadnx-libs-dc61b6ccacb0cd535e125f6e3831c5d0b3d073b4.tar.gz
nx-libs-dc61b6ccacb0cd535e125f6e3831c5d0b3d073b4.tar.bz2
nx-libs-dc61b6ccacb0cd535e125f6e3831c5d0b3d073b4.zip
Args.c: use strdup instead of malloc
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Args.c42
1 files changed, 7 insertions, 35 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c
index 8ee64ba75..6c0160164 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Args.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c
@@ -215,14 +215,10 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
if ((!strcmp(argv[j], "-display")) && (j + 1 < argc))
{
- envOptions = malloc(strlen(argv[j + 1]) + 1);
+ envOptions = strdup(argv[j + 1]);
- if (envOptions != NULL)
- {
- envOptions = strcpy(envOptions, argv[j + 1]);
- }
#ifdef WARNING
- else
+ if (envOptions == NULL)
{
fprintf(stderr, "ddxProcessArgument: WARNING! failed string allocation.\n");
}
@@ -234,14 +230,10 @@ int ddxProcessArgument(int argc, char *argv[], int i)
if ((envOptions == NULL) && (envDisplay != NULL))
{
- envOptions = malloc(strlen(envDisplay) + 1);
+ envOptions = strdup(envDisplay);
- if (envOptions != NULL)
- {
- envOptions = strcpy(envOptions, envDisplay);
- }
#ifdef WARNING
- else
+ if (envOptions == NULL)
{
fprintf(stderr, "ddxProcessArgument: WARNING! failed string allocation.\n");
}
@@ -696,34 +688,14 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
if (++i < argc)
{
- int size;
-
free(nxagentKeyboard);
nxagentKeyboard = NULL;
- if ((size = strlen(argv[i])) < 256)
- {
- if ((nxagentKeyboard = malloc(size + 1)) == NULL)
- {
- FatalError("malloc failed");
- }
-
- strncpy(nxagentKeyboard, argv[i], size);
-
- nxagentKeyboard[size] = '\0';
- }
- #ifdef WARNING
- else
+ nxagentKeyboard = strdup(argv[i]);
+ if (nxagentKeyboard == NULL)
{
- /*
- * it is useless to remember a kbtype
- * option that has just been truncated.
- */
-
- fprintf(stderr, "ddxProcessArgument: WARNING! Option [%s] too long. "
- "It will be ignored.\n", argv[i]);
+ FatalError("malloc failed");
}
- #endif
return 2;
}