summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2018-11-10 12:04:22 +0100
committerGitHub <[email protected]>2018-11-10 12:04:22 +0100
commit657897b493232fd8ee3b9ee4f96463f105b82955 (patch)
treece964279a551d3942ea66ed4e8d9157adc467fa8
parent5167f78d5f64dfe2a4110102a0a7c1ca197d7c75 (diff)
parent80dbe636cd647c48b36db8df70708b4bc5ca1d6f (diff)
downloadraylib-657897b493232fd8ee3b9ee4f96463f105b82955.tar.gz
raylib-657897b493232fd8ee3b9ee4f96463f105b82955.zip
Merge pull request #685 from jubalh/master
Improve OpenURL()
-rw-r--r--src/core.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/core.c b/src/core.c
index da286923..d6c5f243 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1822,22 +1822,20 @@ int StorageLoadValue(int position)
// Open URL with default system browser (if available)
void OpenURL(const char *url)
{
- // Max length is "explorer ".length + url.maxlength (which is 2083),
- // but we are not wasting that much memory here... let's set it up to 512
- static char cmd[512] = { 0 };
+ char *cmd = calloc(10 + strlen(url), sizeof(char));
#if defined(_WIN32)
strcpy(cmd, "explorer ");
+ strcat(cmd, url);
#elif defined(__linux__)
- strcpy(cmd, "xdg-open "); // Alternatives: firefox, x-www-browser
+ sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
#elif defined(__APPLE__)
strcpy(cmd, "open ");
+ strcat(cmd, url);
#endif
- strcat(cmd, url);
system(cmd);
-
- memset(cmd, 0, 512);
+ free(cmd);
}
//----------------------------------------------------------------------------------