Browse Source

Bugfixing previous bugfix in rpn_jit

Yann Weber 3 years ago
parent
commit
6bb5186c8f
3 changed files with 16 additions and 3 deletions
  1. 1
    1
      python_rpnexpr.h
  2. 14
    1
      rpn_jit.c
  3. 1
    1
      rpn_parse.c

+ 1
- 1
python_rpnexpr.h View File

@@ -112,7 +112,7 @@ PyObject* rpnexpr_getstate(PyObject *cls, PyObject *noargs);
112 112
  * @param state Should by a bytes Python instance returned by @ref
113 113
  * rpnexpr_getstate
114 114
  * @return A bytes Python instance suitable as argument for
115
- * @ref rpnexpr_setstate
115
+ * @ref rpnexpr_getstate
116 116
  */
117 117
 PyObject* rpnexpr_setstate(PyObject *cls, PyObject *state);
118 118
 

+ 14
- 1
rpn_jit.c View File

@@ -152,7 +152,6 @@ int rpn_expr_untokenize(rpn_expr_t *expr, rpn_tokenized_t *tokens, char long_op)
152 152
 			goto ret_err;
153 153
 		}
154 154
 	}
155
-	expr->toks.tokens_sz = tokens->tokens_sz;
156 155
 
157 156
 	if(_rpn_expr_end_map(expr))
158 157
 	{
@@ -163,6 +162,20 @@ int rpn_expr_untokenize(rpn_expr_t *expr, rpn_tokenized_t *tokens, char long_op)
163 162
 		return -1;
164 163
 	}
165 164
 
165
+	expr->toks.tokens = malloc(sizeof(rpn_token_t)*tokens->tokens_sz);
166
+	if(!expr->toks.tokens)
167
+	{
168
+		snprintf(expr->err_reason, 128,
169
+			"Unable to allocate memory for tokens : %s",
170
+			strerror(errno));
171
+		expr->state = RPN_ERROR;
172
+		return -1;
173
+	}
174
+	memcpy(expr->toks.tokens, tokens->tokens,
175
+	       sizeof(rpn_token_t)*tokens->tokens_sz);
176
+	expr->toks.tokens_sz = tokens->tokens_sz;
177
+	expr->toks.argc = tokens->argc;
178
+
166 179
 	expr->state = RPN_READY;
167 180
 	return 0;
168 181
 

+ 1
- 1
rpn_parse.c View File

@@ -253,7 +253,7 @@ char* rpn_tokenized_expr(rpn_tokenized_t *tokens, char long_op)
253 253
 				err=errno;
254 254
 				dprintf(2,"Error allocating memory for expression : %s",
255 255
 					strerror(err));
256
-				goto ret_err;
256
+				goto free_err;
257 257
 			}
258 258
 			cur = tmp + (cur - expr);
259 259
 			expr = tmp;

Loading…
Cancel
Save