Skip to content

Commit 815ce12

Browse files
authored
Pr2 fix numerical diff test buffer overflows (#90)
* Fix stack-buffer-overflows in numerical-derivative tests * remove comment
1 parent cb0665d commit 815ce12

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

tests/problem/test_param_broadcast.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ const char *test_const_sum_scalar_mult(void)
192192

193193
problem_init_derivatives(prob);
194194

195-
/* point for evaluating */
196-
double x_vals[1] = {4.0};
195+
double x_vals[6] = {4.0, 0.0, 0.0, 0.0, 0.0, 0.0};
197196

198197
problem_constraint_forward(prob, x_vals);
199198
double constrs[1] = {6.0 * 4.0};
@@ -226,8 +225,7 @@ const char *test_param_sum_scalar_mult(void)
226225
problem_register_params(prob, param_nodes, 1);
227226
problem_init_derivatives(prob);
228227

229-
/* point for evaluating */
230-
double x_vals[1] = {4.0};
228+
double x_vals[6] = {4.0, 0.0, 0.0, 0.0, 0.0, 0.0};
231229

232230
problem_constraint_forward(prob, x_vals);
233231
double constrs[1] = {6.0 * 4.0};

tests/wsum_hess/composite/test_chain_rule_wsum_hess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,13 @@ const char *test_wsum_hess_AX_BX_multiply(void)
300300

301301
const char *test_wsum_hess_multiply_deep_composite(void)
302302
{
303-
double u_vals[4] = {1.0, 2.0, 3.0, 4.0};
303+
double u_vals[8] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
304304
double w[4] = {1.1, 2.2, 3.3, 4.4};
305305

306306
CSR_matrix *A = new_csr_random(2, 2, 1.0);
307307
CSR_matrix *B = new_csr_random(2, 2, 1.0);
308308
expr *X = new_variable(2, 2, 0, 8);
309-
expr *Y = new_variable(2, 2, 0, 8);
309+
expr *Y = new_variable(2, 2, 4, 8);
310310
expr *AX = new_left_matmul(NULL, X, A);
311311
expr *BY = new_left_matmul(NULL, Y, B);
312312
expr *sin_AX = new_sin(AX);

0 commit comments

Comments
 (0)