]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
fixed modification of constant strings 585/head
authorMartin Sperl <kernel@martin.sperl.org>
Tue, 24 Feb 2015 14:00:22 +0000 (14:00 +0000)
committerMartin Sperl <kernel@martin.sperl.org>
Tue, 24 Feb 2015 14:00:22 +0000 (14:00 +0000)
and restored the "original" error-message

src/rrd_graph_helper.c

index 28e5ab2459bf5fd7953fdbdea164c66a9ae68dce..2cf5f71c9a4534551d40bfacefdf8d47f9534865 100644 (file)
@@ -901,12 +901,25 @@ int parse_def(enum gf_en gf,parsedargs_t*pa,image_desc_t *const im){
                                        );
   /* retry in case of errors modifying the name*/
   if (!gdp) {
-         rrd_clear_error();
          /* restart from scratch */
          resetParsedArguments(pa);
-         /* but modify the first parameter */
+         /* get the first parameter */
          keyvalue_t *first= getFirstUnusedArgument(0,pa);
+         /* if it is any of the "original" positional args, then we terminate immediately */
+         for(int i=0;i<10;i++){
+                 if (poskeys[i] == first->key) {
+                         return -1;
+                 }
+         }
+         /* otherwise we patch the key */
          *(first->key)+=128;
+
+         /* and keep a copy of the error */
+         char original_error[4096];
+         strncpy(original_error,rrd_get_error(),sizeof(original_error));
+         /* and clear the error */
+         rrd_clear_error();
+
          /* now run it */
          gdp=newGraphDescription(im,gf,pa,
                                        PARSE_VNAMERRDDSCF
@@ -916,7 +929,11 @@ int parse_def(enum gf_en gf,parsedargs_t*pa,image_desc_t *const im){
                                        |PARSE_REDUCE
                                        |PARSE_RETRY
                                        );
-         if (!gdp) { return 1;}
+         /* on error, we restore the original error and return */
+         if (!gdp) {
+                 rrd_set_error(original_error);
+                 return 1;
+         }
   }
 
   if (gdp->step == 0){