Fixed wrong value in :set+= for integer vars.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 17 Aug 2014 13:30:50 +0000 (15:30 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 17 Aug 2014 20:28:26 +0000 (22:28 +0200)
src/setting.c

index d803b8b..9cc1f9c 100644 (file)
@@ -385,15 +385,16 @@ static gboolean prepare_setting_value(Setting *prop, void *value, SettingType ty
 
     /* perform arithmetic operation for integer values */
     if (prop->type == TYPE_INTEGER) {
-        int newint;
+        int *newint = g_malloc(sizeof(int));
+        res         = true;
         if (type == SETTING_APPEND) {
-            newint = prop->value.i + *((int*)value);
+            *newint = prop->value.i + *((int*)value);
         } else if (type == SETTING_PREPEND) {
-            newint = prop->value.i * *((int*)value);
+            *newint = prop->value.i * *((int*)value);
         } else if (type == SETTING_REMOVE) {
-            newint = prop->value.i - *((int*)value);
+            *newint = prop->value.i - *((int*)value);
         }
-        *newvalue = (void*)&newint;
+        *newvalue = (void*)newint;
         return res;
     }