[gjs] GjsAutoChar: Do not take ownership of const char*



commit fb628a93f0686cf77310f0a05f6ace30aad34138
Author: Daniel Boles <dboles src gnome org>
Date:   Thu Jun 15 09:33:12 2017 +0100

    GjsAutoChar: Do not take ownership of const char*
    
    We were taking a const char* and casting away constness, which would
    enable bad things like freeing a string literal, or double-freeing a
    const char* view of a string that is already owned by another entity.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777597

 gjs/jsapi-util.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 6842e8d..57da626 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -41,8 +41,8 @@ public:
         return get();
     }
 
-    void operator= (const char* str) {
-        reset(const_cast<char*>(str));
+    void operator= (char *str) {
+        reset(str);
     }
 };
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]