File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,11 +14,19 @@ Datum _urlencode_string(PG_FUNCTION_ARGS) {
1414 char * str = text_to_cstring (PG_GETARG_TEXT_P (0 ));
1515 char * urlencoded_str = NULL ;
1616
17- urlencoded_str = curl_escape (str , strlen (str ));
17+ urlencoded_str = curl_easy_escape (NULL , str , strlen (str ));
18+
19+ if (urlencoded_str == NULL ) {
20+ PG_RETURN_NULL ();
21+ }
1822
1923 pfree (str );
2024
21- PG_RETURN_TEXT_P (cstring_to_text (urlencoded_str ));
25+ text * result = cstring_to_text (urlencoded_str );
26+
27+ curl_free (urlencoded_str );
28+
29+ PG_RETURN_TEXT_P (result );
2230}
2331
2432Datum _encode_url_with_params_array (PG_FUNCTION_ARGS ) {
@@ -52,5 +60,9 @@ Datum _encode_url_with_params_array(PG_FUNCTION_ARGS) {
5260 pfree (url );
5361 curl_url_cleanup (h );
5462
55- PG_RETURN_TEXT_P (cstring_to_text (full_url ));
63+ text * result = cstring_to_text (full_url );
64+
65+ curl_free (full_url );
66+
67+ PG_RETURN_TEXT_P (result );
5668}
You can’t perform that action at this time.
0 commit comments