]> granicus.if.org Git - postgresql/commitdiff
This patch removes the initialization of ri in loop in
authorBruce Momjian <bruce@momjian.us>
Sat, 8 Jan 2000 22:58:03 +0000 (22:58 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 8 Jan 2000 22:58:03 +0000 (22:58 +0000)
quote_postgres(...) in ecpglib.c.

The code in CVS reads:

quote_postgres(char *arg, int lineno)
{
 char    *res = (char *) ecpg_alloc(2 * strlen(arg) + 3, lineno);
 int   i,
    ri = 0;

 if (!res)
  return (res);

 res[ri++] = '\'';
 for (i = 0, ri=0; arg[i]; i++, ri++)
 {
  switch (arg[i])
  {
   case '\'':
    res[ri++] = '\'';
    break;
   case '\\':
    res[ri++] = '\\';
    break;
   default:
    ;
  }

The problem here is that ri is reset to 0, thus overwriting the initial
quote.

Stephen Birch

src/interfaces/ecpg/lib/ecpglib.c

index 4c0134c393355f6b0176d8ed82da8fd46e84ac2c..5190dd0635c6409a1904189235873ff38ff17b39 100644 (file)
@@ -238,7 +238,7 @@ quote_postgres(char *arg, int lineno)
                return (res);
 
        res[ri++] = '\'';
-       for (i = 0, ri = 0; arg[i]; i++, ri++)
+       for (i = 0; arg[i]; i++, ri++)
        {
                switch (arg[i])
                {