diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-01-28 21:51:00 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-01 19:53:59 -0800 |
commit | 9b529480074120f8228662ede175bfa65f6ece8c (patch) | |
tree | d3f0d9bcbde778c8b900142855868e177245c509 | |
parent | ea5ada919258d04e003596ee7079c33b5657dbdc (diff) |
Replace Copy_String() with strdup + error check
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
-rw-r--r-- | xprop.c | 25 |
1 files changed, 7 insertions, 18 deletions
@@ -124,22 +124,6 @@ Add_Thunk (thunk *list, thunk t) * Misc. routines */ -static char * -Copy_String (const char *string) -{ - char *new; - int length; - - length = strlen(string) + 1; - - new = malloc(length); - if (!new) - Fatal_Error("Out of memory!"); - memcpy(new, string, length); - - return new; -} - static int Read_Char (FILE *stream) { @@ -190,7 +174,10 @@ Read_Quoted (FILE *stream) } ptr++[0] = '\0'; - return Copy_String(_large_buffer); + ptr = strdup(_large_buffer); + if (!ptr) + Fatal_Error("Out of memory!"); + return ptr; } /* @@ -559,7 +546,9 @@ Read_Mappings (FILE *stream) Fatal_Error("Bad format file format."); atom = Parse_Atom(name, False); - format = Copy_String(format_buffer); + format = strdup(format_buffer); + if (!format) + Fatal_Error("Out of memory!"); Read_White_Space(stream); dformat = D_DFORMAT; |