From 4a8fe5cf3eff503a9cd1f44b59006e907e88fe06 Mon Sep 17 00:00:00 2001 From: Sean Linsley Date: Fri, 3 Jun 2022 13:31:57 -0500 Subject: [PATCH 1/3] add test case for memory leak --- test/fingerprint.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/fingerprint.c b/test/fingerprint.c index 99d9da6b..fe8b5ef8 100644 --- a/test/fingerprint.c +++ b/test/fingerprint.c @@ -37,6 +37,14 @@ int main() pg_query_free_fingerprint_result(result); } + // Ensures that there isn't a memory leak in the error case + PgQueryFingerprintResult result = pg_query_fingerprint("SELECT !"); + if (strcmp(result.error->message, "syntax error at end of input") != 0) { + printf("\nERROR mismatch: %s\n", result.error->message); + return EXIT_FAILURE; + } + pg_query_free_fingerprint_result(result); + printf("\n"); pg_query_exit(); From 63d74a201ad029ee4968280ee355d795581b9c41 Mon Sep 17 00:00:00 2001 From: Sean Linsley Date: Fri, 3 Jun 2022 13:33:42 -0500 Subject: [PATCH 2/3] fix memory leak in pg_query_fingerprint --- src/pg_query_fingerprint.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pg_query_fingerprint.c b/src/pg_query_fingerprint.c index 0c520540..ac9d8952 100644 --- a/src/pg_query_fingerprint.c +++ b/src/pg_query_fingerprint.c @@ -374,6 +374,7 @@ void pg_query_free_fingerprint_result(PgQueryFingerprintResult result) if (result.error) { free(result.error->message); free(result.error->filename); + free(result.error->funcname); free(result.error); } From 2c73a2bcd377ff4d60e71c01d6ec319ff608bae2 Mon Sep 17 00:00:00 2001 From: Sean Linsley Date: Fri, 3 Jun 2022 14:21:18 -0500 Subject: [PATCH 3/3] update README to link to our Rust library --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2082d162..9aa06598 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,7 @@ pg_query wrappers in other languages: * Javascript (Browser): [pg-query-emscripten](https://github.com/pganalyze/pg-query-emscripten) * Python: [psqlparse](https://github.com/alculquicondor/psqlparse), [pglast](https://github.com/lelit/pglast) * OCaml: [pg_query-ocaml](https://github.com/roddyyaga/pg_query-ocaml) -* Rust: [pg_query.rs](https://github.com/paupino/pg_query.rs) +* Rust: [pg_query.rs](https://github.com/pganalyze/pg_query.rs) Products, tools and libraries built on pg_query: