Print this page
9718 update mandoc to 1.14.4

@@ -1,6 +1,6 @@
-/*      $Id: mandoc_aux.c,v 1.10 2017/06/12 19:05:47 schwarze Exp $ */
+/*      $Id: mandoc_aux.c,v 1.11 2018/02/07 20:04:57 schwarze Exp $ */
 /*
  * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any

@@ -109,10 +109,10 @@
 char *
 mandoc_strndup(const char *ptr, size_t sz)
 {
         char    *p;
 
-        p = mandoc_malloc(sz + 1);
-        memcpy(p, ptr, sz);
-        p[(int)sz] = '\0';
+        p = strndup(ptr, sz);
+        if (p == NULL)
+                err((int)MANDOCLEVEL_SYSERR, NULL);
         return p;
 }