utils: fix typo in strndup fallback
[platform/upstream/libxkbcommon.git] / src / utils.h
index d796e10..920db4c 100644 (file)
@@ -119,7 +119,7 @@ strndup(const char *s, size_t n)
     char *p = malloc(len + 1);
     if (!p)
         return NULL;
-    memcpy(p, str, len);
+    memcpy(p, s, len);
     p[len] = '\0';
     return p;
 }
@@ -259,4 +259,12 @@ unmap_file(char *string, size_t size);
 #define ATTR_PACKED
 #endif
 
+#if !(defined(HAVE_ASPRINTF) && HAVE_ASPRINTF)
+int asprintf(char **strp, const char *fmt, ...) ATTR_PRINTF(2, 3);
+# if !(defined(HAVE_VASPRINTF) && HAVE_VASPRINTF)
+#  include <stdarg.h>
+int vasprintf(char **strp, const char *fmt, va_list ap);
+# endif /* !HAVE_VASPRINTF */
+#endif /* !HAVE_ASPRINTF */
+
 #endif /* UTILS_H */