I wasn't seeing the coredumps my error message patch (in 0.96) produced until
I tried it on a Linux machine. However, the replacement in 0.98 has a bug
where it checks the destination for its termination condition when copying the
error message, rather than the source. I don't know whether Postgres produces
any multi-line error messages, but these would also be truncated by the 0.98
code. So here's a patch which fixes both problems. If there are no multi-line
errors, then just change *dst to *src in the copying loop condition.

--- dbdimp.c.orig       Tue May  1 11:46:47 2001
+++ dbdimp.c    Tue May  1 11:55:26 2001
@@ -72,18 +72,21 @@
     char *error_msg;
 {
     D_imp_xxh(h);
-    char *err, *src, *dst; 
+    char *err, *src, *dst, *end; 
     int  len  = strlen(error_msg);
 
-    err = (char *)malloc(strlen(error_msg + 1));
+    err = (char *)malloc(len + 1);
     if (!err) {
       return;
     }
+    /* Remove trailing newlines, allowing for multi-line messages */
+    for(end = error_msg + len; end > error_msg && end[-1] == '\n'; --end);
+    
     src = error_msg;
     dst = err;
 
     /* copy error message without trailing newlines */
-    while (*dst != '\0' && *dst != '\n') {
+    while (src < end){
         *dst++ = *src++;
     }
     *dst = '\0';

-- 
        Peter Haworth   [EMAIL PROTECTED]
"I find the urge to lick the screen most disturbing."
                -- Elaine Ashton, talking about MacOS X

Reply via email to