Patch for 0.53 Release Candidate 2

JADelinck at uss.com JADelinck at uss.com
Tue Dec 18 11:23:29 EST 2001



I have had the following simple problems with freetds 0.53 RC 2.

1. I cannot fflush a NULL file stream.
2. I cannot free a NULL pointer.
3. I do not have vsnprintf.
4. I cannot #include netdb.h twice

Here is the patch. I don't believe it will cause any problems in other
areas.

diff -c -r old/freetds-0.53/configure.in freetds-0.53/configure.in
*** old/freetds-0.53/configure.in  Tue Nov 13 22:52:33 2001
--- freetds-0.53/configure.in Tue Dec 18 09:24:49 2001
***************
*** 102,108 ****
  dnl ------------------------------------------------------------
  dnl Checks for library functions.
  dnl ------------------------------------------------------------
!

  dnl ------------------------------------------------------------
  dnl Compile time options
--- 102,108 ----
  dnl ------------------------------------------------------------
  dnl Checks for library functions.
  dnl ------------------------------------------------------------
! AC_CHECK_FUNCS(vsnprintf)

  dnl ------------------------------------------------------------
  dnl Compile time options
diff -c -r old/freetds-0.53/include/tds.h freetds-0.53/include/tds.h
*** old/freetds-0.53/include/tds.h Sun Dec 16 09:39:38 2001
--- freetds-0.53/include/tds.h     Mon Dec 17 14:03:02 2001
***************
*** 34,40 ****
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>
! #include <netdb.h>
  #include <sys/signal.h>
  #include <sys/wait.h>
  #endif
--- 34,40 ----
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>
! /* #include <netdb.h> */
  #include <sys/signal.h>
  #include <sys/wait.h>
  #endif
diff -c -r old/freetds-0.53/include/tds.h.in freetds-0.53/include/tds.h.in
*** old/freetds-0.53/include/tds.h.in    Sun Dec  2 18:06:14 2001
--- freetds-0.53/include/tds.h.in  Mon Dec 17 12:21:39 2001
***************
*** 34,40 ****
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>
! #include <netdb.h>
  #include <sys/signal.h>
  #include <sys/wait.h>
  #endif
--- 34,40 ----
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>
! /* #include <netdb.h> */
  #include <sys/signal.h>
  #include <sys/wait.h>
  #endif
diff -c -r old/freetds-0.53/src/dblib/dblib.c
freetds-0.53/src/dblib/dblib.c
*** old/freetds-0.53/src/dblib/dblib.c   Thu Nov 22 17:37:16 2001
--- freetds-0.53/src/dblib/dblib.c Tue Dec 18 09:28:54 2001
***************
*** 464,470 ****
--- 464,488 ----
  int n, size = 1024;
  int done = 0;
  RETCODE ret;
+ #ifndef HAVE_VSNPRINTF
+ FILE * devnul;

+    devnul = fopen("/dev/null", "w");
+    if(devnul == NULL) return FAIL;
+    va_start(ap, fmt);
+    n = vfprintf(devnul, fmt, ap);
+    va_end(ap);
+    fclose(devnul);
+    tmpstr = (char *)malloc (n+1);
+    if (!tmpstr) return FAIL;
+    va_start(ap, fmt);
+    n = vsprintf (tmpstr, fmt, ap);
+    va_end(ap);
+    if (n<0) {
+         free(tmpstr);
+         return FAIL;
+    }
+ #else  /*  HAVE_VSNPRINTF */
          tmpstr = (char *)malloc (size);
     if (!tmpstr) return FAIL;

***************
*** 483,489 ****
          tmpstr = realloc (tmpstr, size);
          if (!tmpstr) return FAIL;
     }
!
          ret = dbcmd(dbproc, tmpstr);
     free(tmpstr);

--- 501,507 ----
          tmpstr = realloc (tmpstr, size);
          if (!tmpstr) return FAIL;
     }
! #endif /* ! HAVE_VSNPRINTF */
          ret = dbcmd(dbproc, tmpstr);
     free(tmpstr);

diff -c -r old/freetds-0.53/src/tds/mem.c freetds-0.53/src/tds/mem.c
*** old/freetds-0.53/src/tds/mem.c Sun Dec  2 18:06:14 2001
--- freetds-0.53/src/tds/mem.c     Mon Dec 17 15:02:58 2001
***************
*** 107,113 ****
          tds_free_input_params(dyn);
          free(dyn);
     }
!    free(tds->dyns);
     tds->dyns = NULL;
     tds->num_dyns = 0;

--- 107,114 ----
          tds_free_input_params(dyn);
          free(dyn);
     }
!    if(tds->dyns != NULL)
!      free(tds->dyns);
     tds->dyns = NULL;
     tds->num_dyns = 0;

diff -c -r old/freetds-0.53/src/tds/util.c freetds-0.53/src/tds/util.c
*** old/freetds-0.53/src/tds/util.c      Fri Nov  9 20:39:01 2001
--- freetds-0.53/src/tds/util.c    Mon Dec 17 14:51:58 2001
***************
*** 365,371 ****
           }
        }
     }
!    fflush(dumpfile);
     if (g_append_mode && ret) {
        fclose(dumpfile);
     }
--- 365,372 ----
           }
        }
     }
!    if(dumpfile != NULL)
!      fflush(dumpfile);
     if (g_append_mode && ret) {
        fclose(dumpfile);
     }







More information about the FreeTDS mailing list