diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-20 13:03:15 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-22 22:28:47 -0800 |
commit | 0384b1c6567d3f90975665ed4e7b3a09947cabee (patch) | |
tree | 56bbf5059466da5c116771211ab7f2a9689d08a0 | |
parent | 7dba9bf178878e09aaad09be9ed9bdccb60c08b9 (diff) |
Replace strlen/malloc/memcpy set with strdup
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | xprop.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -985,7 +985,6 @@ Format_Len_Unicode (const char *string, int len) { char *data; const char *result, *error; - int len2; int validity = is_valid_utf8(string, len); @@ -1004,11 +1003,11 @@ Format_Len_Unicode (const char *string, int len) } result = Format_Len_String(string, len); - len2 = strlen(result); - data = malloc(len2+1); + /* result is stored in _formatting_buffer, so make a temporary + copy before we overwrite _formatting_buffer with error */ + data = strdup(result); if (!data) Fatal_Error("Out of memory!"); - memcpy(data, result, len2+1); memcpy(_formatting_buffer, error, strlen(error)+1); strcat(_formatting_buffer, data); |