This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x in repository nx-libs. commit dc61b6ccacb0cd535e125f6e3831c5d0b3d073b4 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Jan 3 00:32:14 2018 +0100 Args.c: use strdup instead of malloc --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 42 ++++++------------------------- 1 file 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 8ee64ba..6c01601 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; } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git