projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow compilation from a build directory
[tinc]
/
src
/
xmalloc.c
diff --git
a/src/xmalloc.c
b/src/xmalloc.c
index
1e40017
..
1f354dd
100644
(file)
--- a/
src/xmalloc.c
+++ b/
src/xmalloc.c
@@
-16,7
+16,7
@@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#if HAVE_CONFIG_H
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#if HAVE_CONFIG_H
-# include "
../
config.h"
+# include "config.h"
#endif
#include <sys/types.h>
#endif
#include <sys/types.h>
@@
-113,6
+113,9
@@
char *xstrdup(const char *s)
{
char *p;
{
char *p;
+ if(!s)
+ return NULL;
+
p = strdup(s);
if(!p)
xalloc_fail ((int)strlen(s));
p = strdup(s);
if(!p)
xalloc_fail ((int)strlen(s));
@@
-152,6
+155,7
@@
int xvasprintf(char **strp, const char *fmt, va_list ap) {
int result = vsnprintf(buf, sizeof buf, fmt, ap);
if(result < 0)
exit(xalloc_exit_failure);
int result = vsnprintf(buf, sizeof buf, fmt, ap);
if(result < 0)
exit(xalloc_exit_failure);
+ buf[sizeof buf - 1] = 0;
*strp = xstrdup(buf);
#else
int result = vasprintf(strp, fmt, ap);
*strp = xstrdup(buf);
#else
int result = vasprintf(strp, fmt, ap);