• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / pg_net / 30975371118

05 Aug 2026 04:31AM UTC coverage: 94.074% (-0.1%) from 94.195%
30975371118

Pull #273

github

web-flow
Merge e861c0ceb into 35907ebbd
Pull Request #273: fix: a couple of memory leaks

8 of 9 new or added lines in 1 file covered. (88.89%)

508 of 540 relevant lines covered (94.07%)

227.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.3
/src/util.c
1
#include "pg_prelude.h"
2

3
#include "curl_prelude.h"
4

5
#include "errors.h"
6
#include "util.h"
7

8
PG_FUNCTION_INFO_V1(_urlencode_string);
114✔
9
PG_FUNCTION_INFO_V1(_encode_url_with_params_array);
115✔
10

11
Datum _urlencode_string(PG_FUNCTION_ARGS) {
13✔
12
  if (PG_GETARG_POINTER(0) == NULL) PG_RETURN_NULL();
13✔
13

14
  char *str            = text_to_cstring(PG_GETARG_TEXT_P(0));
12✔
15
  char *urlencoded_str = NULL;
12✔
16

17
  urlencoded_str = curl_easy_escape(NULL, str, strlen(str));
12✔
18

19
  if (urlencoded_str == NULL) {
12✔
NEW
20
    PG_RETURN_NULL();
×
21
  }
22

23
  pfree(str);
12✔
24

25
  text *result = cstring_to_text(urlencoded_str);
12✔
26

27
  curl_free(urlencoded_str);
12✔
28

29
  PG_RETURN_TEXT_P(result);
12✔
30
}
31

32
Datum _encode_url_with_params_array(PG_FUNCTION_ARGS) {
508✔
33
  if (PG_GETARG_POINTER(0) == NULL || PG_GETARG_POINTER(1) == NULL) PG_RETURN_NULL();
508✔
34

35
  char      *url    = text_to_cstring(PG_GETARG_TEXT_P(0));
504✔
36
  ArrayType *params = PG_GETARG_ARRAYTYPE_P(1);
504✔
37

38
  char *full_url = NULL;
504✔
39

40
  ArrayIterator iterator;
504✔
41
  Datum         value;
504✔
42
  bool          isnull;
504✔
43
  char         *param;
504✔
44

45
  CURLU *h = curl_url();
504✔
46
  EREPORT_CURL_URL_SET(h, CURLUPART_URL, url, 0);
504✔
47

48
  iterator = array_create_iterator(params, 0, NULL);
502✔
49
  while (array_iterate(iterator, &value, &isnull)) {
508✔
50
    if (isnull) continue;
6✔
51

52
    param = TextDatumGetCString(value);
6✔
53
    EREPORT_CURL_URL_SET(h, CURLUPART_QUERY, param, CURLU_APPENDQUERY);
6✔
54
    pfree(param);
6✔
55
  }
56
  array_free_iterator(iterator);
502✔
57

58
  EREPORT_CURL_URL_GET(h, CURLUPART_URL, &full_url, 0, url);
502✔
59

60
  pfree(url);
502✔
61
  curl_url_cleanup(h);
502✔
62

63
  text *result = cstring_to_text(full_url);
502✔
64

65
  curl_free(full_url);
502✔
66

67
  PG_RETURN_TEXT_P(result);
502✔
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc