Commit 7f00938c authored by Alan Coopersmith's avatar Alan Coopersmith

Use asprintf if available, instead of malloc+strcpy+strcat

Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent 538ddd32
......@@ -8,6 +8,7 @@ AC_INIT([xcursorgen],
[xcursorgen])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_USE_SYSTEM_EXTENSIONS
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-bzip2])
......@@ -21,6 +22,8 @@ XORG_DEFAULT_OPTIONS
# Checks for pkg-config packages
PKG_CHECK_MODULES(XCURSORGEN, x11 xcursor libpng >= 1.2.0)
AC_CHECK_FUNCS([asprintf])
AC_CONFIG_FILES([
Makefile
man/Makefile])
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment