diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-08-25 14:47:01 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-08-25 15:16:28 -0700 |
commit | 7f00938c6d4499d78b61feaddb4bfb6af00f6e26 (patch) | |
tree | 6752b0459903f5678bda6bfcc60c28418519bd9c /xcursorgen.c | |
parent | 538ddd32790f0031357807b1b0c6c10879607209 (diff) |
Use asprintf if available, instead of malloc+strcpy+strcat
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xcursorgen.c')
-rw-r--r-- | xcursorgen.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/xcursorgen.c b/xcursorgen.c index ba9d85c..2aa116c 100644 --- a/xcursorgen.c +++ b/xcursorgen.c @@ -210,6 +210,15 @@ load_image (struct flist *list, const char *prefix) if (prefix) { +#ifdef HAVE_ASPRINTF + if (asprintf(&file, "%s/%s", prefix, list->pngfile) == -1) + { + fprintf (stderr, "%s: asprintf() failed: %s\n", + ProgramName, strerror(errno)); + png_destroy_read_struct (&png, &info, NULL); + return NULL; + } +#else file = malloc (strlen (prefix) + 1 + strlen (list->pngfile) + 1); if (file == NULL) { @@ -221,6 +230,7 @@ load_image (struct flist *list, const char *prefix) strcpy (file, prefix); strcat (file, "/"); strcat (file, list->pngfile); +#endif } else file = list->pngfile; |