Make some insufficient effort to not leak memory in bt support 1 routine
authorPeter Geoghegan <[email protected]>
Wed, 12 Mar 2014 04:16:24 +0000 (21:16 -0700)
committerPeter Geoghegan <[email protected]>
Wed, 12 Mar 2014 04:16:24 +0000 (21:16 -0700)
src/backend/utils/adt/jsonb_op.c
src/backend/utils/adt/jsonb_support.c

index 6c138339f8fe0f29055e1735d419875c0f541c7d..3ba57f4f9d0d39fafcdc46b43e6a0ae1d8b0f1e4 100644 (file)
@@ -246,6 +246,9 @@ jsonb_cmp(PG_FUNCTION_ARGS)
    }
    else
    {
+       /*
+        * TODO: Think harder about the memory leaked here
+        */
        res = compareJsonbBinaryValue(VARDATA(jb1), VARDATA(jb2));
    }
 
index 327c54c625cb55917d96b1c356f1126e72a3855d..ee86e55e584e02936d91b65c2b3610201b406514 100644 (file)
@@ -206,6 +206,8 @@ compareJsonbValue(JsonbValue * a, JsonbValue * b)
  * Gives consistent ordering of Jsonb values.
  *
  * Strings are compared lexically, making this suitable as a sort comparator.
+ *
+ * This is called from B-Tree support function 1.
  */
 int
 compareJsonbBinaryValue(char *a, char *b)
@@ -273,6 +275,9 @@ compareJsonbBinaryValue(char *a, char *b)
        }
    }
 
+   pfree(it1);
+   pfree(it2);
+
    return res;
 }