r20295 - gnucash/trunk/src/backend/dbi - Bug #641832: Use g_strdup_printf() instead of dbi_conn_queryf() to format the query; the latter crashed msvcrt. Also reverts r20287 because the root bug is fixed.

John Ralls jralls at code.gnucash.org
Sun Feb 13 15:03:12 EST 2011


Author: jralls
Date: 2011-02-13 15:03:12 -0500 (Sun, 13 Feb 2011)
New Revision: 20295
Trac: http://svn.gnucash.org/trac/changeset/20295

Modified:
   gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
Log:
Bug #641832: Use g_strdup_printf() instead of dbi_conn_queryf() to format the query; the latter crashed msvcrt. Also reverts r20287 because the root bug is fixed.

Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c	2011-02-12 21:55:57 UTC (rev 20294)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c	2011-02-13 20:03:12 UTC (rev 20295)
@@ -2875,16 +2875,10 @@
     guint64 testulonglong = 9223372036854775807LLU, resultulonglong = 0;
     gdouble testdouble = 1.7976921348623157E+307, resultdouble = 0.0;
     dbi_result result;
-    gchar doublestr[G_ASCII_DTOSTR_BUF_SIZE];
+    gchar doublestr[G_ASCII_DTOSTR_BUF_SIZE], *querystr;
     gboolean retval = TRUE;
+    memset( doublestr, 0, sizeof(doublestr));
 
-#if G_OS_WIN32
-    /* Bug #641832: On win32 the queryf() calls below seem to
-     * crash. On the other hand, we know the used libdbi on windows is
-     * fine, so as a first workaround, we assume libdbi is safe. */
-    return TRUE;
-#endif
-
     result = dbi_conn_query( conn, "CREATE TEMPORARY TABLE numtest "
                              "( test_int BIGINT, test_unsigned BIGINT,"
                              " test_double FLOAT8 )" );
@@ -2895,10 +2889,11 @@
     }
     dbi_result_free( result );
     g_ascii_dtostr( doublestr, sizeof(doublestr), testdouble );
-    result = dbi_conn_queryf( conn,
-                              "INSERT INTO numtest VALUES (%" G_GINT64_FORMAT
-                              ", %" G_GUINT64_FORMAT ", %s)",
-                              testlonglong, testulonglong, doublestr );
+    querystr = g_strdup_printf( "INSERT INTO numtest VALUES (%" G_GINT64_FORMAT
+				", %" G_GUINT64_FORMAT ", %s)",
+				testlonglong, testulonglong, doublestr );
+    result = dbi_conn_query( conn, querystr );
+    g_free( querystr );
     if ( result == NULL )
     {
         PWARN("Test_DBI_Library: Failed to insert test row into table" );



More information about the gnucash-changes mailing list