Permalink
Browse files

Fix strlcpy / strlcat detection in configure.ac, fix small memory lea…

…k in pgdbf.c

Verified to build on Mac OS X 10.7 and Arch Linux.
  • Loading branch information...
1 parent 2279f79 commit 5773830c8054405881dcec644bd91adef0a83621 @philwo philwo committed Mar 25, 2012
Showing with 18 additions and 1 deletion.
  1. +6 −0 config.h.in
  2. +1 −1 configure.ac
  3. +10 −0 src/pgdbf.c
  4. +1 −0 src/pgdbf.h
View
6 config.h.in
@@ -43,6 +43,12 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
View
2 configure.ac
@@ -30,7 +30,7 @@ AC_C_BIGENDIAN
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MMAP
-AC_CHECK_FUNCS([munmap strchr])
+AC_CHECK_FUNCS([munmap strchr strlcpy strlcat])
AC_ARG_ENABLE([installdocs],
[ --enable-installdocs install documentation],
View
10 src/pgdbf.c
@@ -29,6 +29,14 @@
#include <sys/stat.h>
#include <sys/types.h>
+#if !defined (HAVE_STRLCPY)
+#include "strlcpy.h"
+#endif
+
+#if !defined (HAVE_STRLCAT)
+#include "strlcat.h"
+#endif
+
#include "pgdbf.h"
int main(int argc, char **argv) {
@@ -763,6 +771,8 @@ int main(int argc, char **argv) {
close(memofd);
}
+ free(optvalidargs);
+
#if defined(HAVE_ICONV_H)
if(conv_desc != NULL) {
if(iconv_close(conv_desc) != 0) {
View
1 src/pgdbf.h
@@ -305,6 +305,7 @@ static void safeprintbuf(const char *buf, const size_t inputsize) {
}
}
*t = '\0';
+
printf("%s", targetbuf);
#if defined(HAVE_ICONV_H)

0 comments on commit 5773830

Please sign in to comment.