]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
fixed memory leaks for strftime_format and rootcommand
[chaz/openbox] / src / Screen.cc
index 445156713b9e4ed51eaf0e13682cf3dec471ab96..0548f5acb5e8f86fc256689cf0efd8534e721396 100644 (file)
@@ -1192,8 +1192,15 @@ void BScreen::load() {
   rname.seekp(0); rclass.seekp(0);
   rname << rscreen.str() << "strftimeFormat" << ends;
   rclass << rscreen.str() << "StrftimeFormat" << ends;
-  if (config.getValue(rname.str(), rclass.str(), s))
+
+  if (resource.strftime_format != NULL){
+    delete [] resource.strftime_format;
+    resource.strftime_format=NULL;
+  }
+
+  if (config.getValue(rname.str(), rclass.str(), s)) {
     resource.strftime_format = bstrdup(s.c_str());
+  }
 #else // !HAVE_STRFTIME
   rname.seekp(0); rclass.seekp(0);
   rname << rscreen.str() << "dateFormat" << ends;
@@ -1230,8 +1237,14 @@ void BScreen::load() {
   rname.seekp(0); rclass.seekp(0);
   rname << rscreen.str() << "rootCommand" << ends;
   rclass << rscreen.str() << "RootCommand" << ends;
-  if (config.getValue(rname.str(), rclass.str(), s))
+
+  if (resource.root_command != NULL){
+    delete [] resource.root_command;
+    resource.root_command=NULL;
+  }
+  if (config.getValue(rname.str(), rclass.str(), s)) {
     resource.root_command = bstrdup(s.c_str());
+  }
 
   rname.seekp(0); rclass.seekp(0);
   rname << rscreen.str() << "opaqueMove" << ends;
This page took 0.023588 seconds and 4 git commands to generate.