summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-11-14 00:05:54 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-11-14 00:05:54 +0100
commit02f58b0b3f13b51395fc55d03afdbb445ba58b8d (patch)
treec321515a7d5caa1995d850dd24fb4ac19494db79
parent77460e797c950f6a2c742cc8604a58b5deb86616 (diff)
Fix: free(): invalid next size (normal)
Wrong str allocation leads to crash binding ! Change-Id: I58f6e1c6585a97a7221a6a309bd2d98bf634f111 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--src/qlibwindowmanager.cpp3
-rw-r--r--src/qlibwindowmanager.h2
2 files changed, 2 insertions, 3 deletions
diff --git a/src/qlibwindowmanager.cpp b/src/qlibwindowmanager.cpp
index b5fad2c..bc313e5 100644
--- a/src/qlibwindowmanager.cpp
+++ b/src/qlibwindowmanager.cpp
@@ -33,8 +33,7 @@ int QLibWindowmanager::init(int port, const QString &token) {
int QLibWindowmanager::requestSurface(const QString &label) {
string cstr = label.toStdString();
- applabel = new char[cstr.length() + 1];
- memcpy(applabel, cstr.c_str(), cstr.length() + 1);
+ applabel = strdup(cstr.c_str());
json_object *obj = json_object_new_object();
json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(applabel));
diff --git a/src/qlibwindowmanager.h b/src/qlibwindowmanager.h
index f07a312..6b796f6 100644
--- a/src/qlibwindowmanager.h
+++ b/src/qlibwindowmanager.h
@@ -59,7 +59,7 @@ public slots:
private:
LibWindowmanager* wm;
- char* applabel;
+ const char* applabel;
bool isActive;
};