From 30a1edd40ef77b1bbbd90be7c848985f064f7060 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 12 Nov 2018 00:34:32 +0100 Subject: [PATCH] Review OpenURL() --- src/core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core.c b/src/core.c index d6c5f243..1f4707c8 100644 --- a/src/core.c +++ b/src/core.c @@ -1822,19 +1822,17 @@ int StorageLoadValue(int position) // Open URL with default system browser (if available) void OpenURL(const char *url) { - char *cmd = calloc(10 + strlen(url), sizeof(char)); + char *cmd = calloc(strlen(url) + 10, sizeof(char)); #if defined(_WIN32) - strcpy(cmd, "explorer "); - strcat(cmd, url); + sprintf(cmd, "explorer '%s'", url); #elif defined(__linux__) sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser #elif defined(__APPLE__) - strcpy(cmd, "open "); - strcat(cmd, url); + sprintf(cmd, "open '%s'", url); #endif - system(cmd); + free(cmd); }