diff options
author | Dominique Leuenberger <dimstar@opensuse.org> | 2020-06-02 14:55:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 14:55:55 +0200 |
commit | d6990f4aaab4b947a490ab1abfd9ac6e62d66d7a (patch) | |
tree | a08a16dfd699a48b9f2698e1327d9e9610d30697 | |
parent | dde4cdb5af1d65d0610f1860c5289289685bb62f (diff) | |
parent | 738785214546ec5bb772886019529b2a6519deaf (diff) | |
download | libproxy-git-d6990f4aaab4b947a490ab1abfd9ac6e62d66d7a.tar.gz |
Merge pull request #118 from smcv/mozjs-freed-string
mozjs: Avoid use-after-free
-rw-r--r-- | libproxy/modules/pacrunner_mozjs.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libproxy/modules/pacrunner_mozjs.cpp b/libproxy/modules/pacrunner_mozjs.cpp index ade6d0a..aac6531 100644 --- a/libproxy/modules/pacrunner_mozjs.cpp +++ b/libproxy/modules/pacrunner_mozjs.cpp @@ -175,14 +175,11 @@ public: string run(const url& url_) throw (bad_alloc) { // Build arguments to the FindProxyForURL() function - const char *tmpurl = url_.to_string().c_str(); - const char *tmphost = url_.get_host().c_str(); - if (!tmpurl || !tmphost) { - throw bad_alloc(); - } + string tmpurl(url_.to_string()); + string tmphost(url_.get_host()); JS::AutoValueArray<2> args(this->jsctx); - args[0].setString(JS_NewStringCopyZ(this->jsctx, tmpurl)); - args[1].setString(JS_NewStringCopyZ(this->jsctx, tmphost)); + args[0].setString(JS_NewStringCopyZ(this->jsctx, tmpurl.c_str())); + args[1].setString(JS_NewStringCopyZ(this->jsctx, tmphost.c_str())); // Find the proxy (call FindProxyForURL()) JS::RootedValue rval(this->jsctx); |