While looking at some compilerwarnings I found an alloca and an
strcpy.
What is wrong with that? I don't see any problem in it.
And I realized this can also be done as follows:
+ if ((error_msg = strdup(error_message)) == NULL)
+errx(1, "Out of memory.");
This
Han Boetes <[EMAIL PROTECTED]> writes:
> Advantages are:
>
> - simpler code
Not really.
> - strdup is more portable
Not more than alloca.
> - error handling
Which error?
> - you don't have to worry about strdup concerning security
The code you changed is already obviously safe.
> I
Han Boetes <[EMAIL PROTECTED]> writes:
> While looking at some compilerwarnings I found an alloca and an
> strcpy. And I realized this can also be done as follows:
>
>
> Index: xterm.c
> ===
> RCS file: /cvsroot/emacs/emacs/src/xterm
Hi,
> - error_msg = (char *) alloca (strlen (error_message) + 1);
> - strcpy (error_msg, error_message);
> + if ((error_msg = strdup(error_message)) == NULL)
> +errx(1, "Out of memory.");
> +
I wonder who will release the memory chunk allocated by strdup.