Skip to content

Commit 3066f48

Browse files
committed
Revert "Security patch from Claude Code."
This reverts commit fdc1e0e.
1 parent c7996ef commit 3066f48

23 files changed

Lines changed: 256 additions & 546 deletions

‎src/common/curve_tools.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ float spline_cubic_val(int n, float t[], float tval, float y[], float ypp[])
664664
int CurveDataSample(CurveData *curve, CurveSample *sample)
665665
{
666666
int n = 0;
667-
const int num_anchors = curve->m_numAnchors > MAX_ANCHORS ? MAX_ANCHORS : curve->m_numAnchors;
668667

669668
float x[20] = { 0 };
670669
float y[20] = { 0 };
@@ -687,12 +686,12 @@ int CurveDataSample(CurveData *curve, CurveSample *sample)
687686
}
688687
else
689688
{
690-
for(int i = 0; i < num_anchors; i++)
689+
for(int i = 0; i < curve->m_numAnchors; i++)
691690
{
692691
x[i] = curve->m_anchors[i].x * box_width + curve->m_min_x;
693692
y[i] = curve->m_anchors[i].y * box_height + curve->m_min_y;
694693
}
695-
n = num_anchors;
694+
n = curve->m_numAnchors;
696695
}
697696
const float res = 1.0 / (float)(sample->m_samplingRes - 1);
698697
const int firstPointX = x[0] * (sample->m_samplingRes - 1);
@@ -742,3 +741,4 @@ int CurveDataSample(CurveData *curve, CurveSample *sample)
742741
// vim: shiftwidth=2 expandtab tabstop=2 cindent
743742
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
744743
// clang-format on
744+

‎src/common/spektra_sim.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,8 +2451,6 @@ static void _sf_morph_channel(const double centers_in[],
24512451
double sigmas_out[],
24522452
double gumbel_mix_out[])
24532453
{
2454-
if(nl <= 0) return;
2455-
24562454
int order[SF_GRAIN_MAX_SUBLAYERS];
24572455
for(int i = 0; i < nl; i++) order[i] = i;
24582456
for(int i = 0; i < nl; i++)

‎src/gui/draw.h‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,6 @@ static inline void dt_draw_curve_set_point(dt_draw_curve_t *c,
628628
const float x,
629629
const float y)
630630
{
631-
if(num < 0 || num >= MAX_ANCHORS) return;
632631
c->c.m_anchors[num].x = x;
633632
c->c.m_anchors[num].y = y;
634633
}
@@ -709,20 +708,19 @@ static inline void dt_draw_curve_calc_values_V2(dt_draw_curve_t *c,
709708

710709
static inline float dt_draw_curve_calc_value(dt_draw_curve_t *c, const float x)
711710
{
712-
float xa[MAX_ANCHORS], ya[MAX_ANCHORS];
711+
float xa[20], ya[20];
713712
float val = 0.f;
714713
float *ypp = NULL;
715-
const int num_anchors = MIN((int)c->c.m_numAnchors, MAX_ANCHORS);
716714

717-
for(int i = 0; i < num_anchors; i++)
715+
for(int i = 0; i < c->c.m_numAnchors; i++)
718716
{
719717
xa[i] = c->c.m_anchors[i].x;
720718
ya[i] = c->c.m_anchors[i].y;
721719
}
722-
ypp = interpolate_set(num_anchors, xa, ya, c->c.m_spline_type);
720+
ypp = interpolate_set(c->c.m_numAnchors, xa, ya, c->c.m_spline_type);
723721
if(ypp)
724722
{
725-
val = interpolate_val(num_anchors, xa, x, ya, ypp, c->c.m_spline_type);
723+
val = interpolate_val(c->c.m_numAnchors, xa, x, ya, ypp, c->c.m_spline_type);
726724
free(ypp);
727725
}
728726
return MIN(MAX(val, c->c.m_min_y), c->c.m_max_y);
@@ -732,7 +730,6 @@ static inline void dt_draw_curve_add_point(dt_draw_curve_t *c,
732730
const float x,
733731
const float y)
734732
{
735-
if(c->c.m_numAnchors >= MAX_ANCHORS) return;
736733
c->c.m_anchors[c->c.m_numAnchors].x = x;
737734
c->c.m_anchors[c->c.m_numAnchors].y = y;
738735
c->c.m_numAnchors++;

‎src/iop/ashift.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,24 +3123,23 @@ static gboolean _draw_retrieve_lines_from_params(dt_iop_module_t *self,
31233123
}
31243124
}
31253125

3126-
const int count = CLAMP(p->last_drawn_lines_count, 0, MAX_SAVED_LINES);
3127-
if(method == ASHIFT_METHOD_LINES && count > 0)
3126+
if(method == ASHIFT_METHOD_LINES && p->last_drawn_lines_count > 0)
31283127
{
31293128
float pts[MAX_SAVED_LINES * 4] = { 0.0f };
31303129

3131-
for(int i = 0; i < count * 4; i++)
3130+
for(int i = 0; i < p->last_drawn_lines_count * 4; i++)
31323131
pts[i] = p->last_drawn_lines[i];
31333132

31343133
if(dt_dev_distort_transform_plus(self->dev, self->dev->preview_pipe, self->iop_order,
31353134
DT_DEV_TRANSFORM_DIR_BACK_EXCL, pts,
3136-
count * 2))
3135+
p->last_drawn_lines_count * 2))
31373136
{
31383137
if(g->lines) free(g->lines);
3139-
g->lines = calloc(count, sizeof(dt_iop_ashift_line_t));
3138+
g->lines = calloc(p->last_drawn_lines_count, sizeof(dt_iop_ashift_line_t));
31403139

31413140
int vnb = 0; // number of vertical lines
31423141
int hnb = 0; // number of horizontal lines
3143-
for(int i = 0; i < count; i++)
3142+
for(int i = 0; i < p->last_drawn_lines_count; i++)
31443143
{
31453144
// determine if the line is vertical or horizontal
31463145
dt_iop_ashift_linetype_t linetype = ASHIFT_LINE_VERTICAL_SELECTED;
@@ -3157,7 +3156,7 @@ static gboolean _draw_retrieve_lines_from_params(dt_iop_module_t *self,
31573156
hnb++;
31583157
}
31593158

3160-
g->lines_count = count;
3159+
g->lines_count = p->last_drawn_lines_count;
31613160
g->vertical_count = vnb;
31623161
g->horizontal_count = hnb;
31633162
g->vertical_weight = (float)vnb;

‎src/iop/basecurve.c‎

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ typedef struct dt_iop_basecurve_params_t
7373
dt_iop_rgb_norms_t preserve_colors; /* $DEFAULT: DT_RGB_NORM_LUMINANCE $DESCRIPTION: "preserve colors" */
7474
} dt_iop_basecurve_params_t;
7575

76-
static inline int _basecurve_nodes(const int nodes)
77-
{
78-
return CLAMP(nodes, 0, MAXNODES);
79-
}
80-
8176
int legacy_params(dt_iop_module_t *self,
8277
const void *const old_params,
8378
const int old_version,
@@ -1414,16 +1409,15 @@ void commit_params(dt_iop_module_t *self,
14141409
d->preserve_colors = p->preserve_colors;
14151410

14161411
const int ch = 0;
1417-
const int nodes = _basecurve_nodes(p->basecurve_nodes[ch]);
14181412
// take care of possible change of curve type or number of nodes (not yet implemented in UI)
1419-
if(d->basecurve_type != p->basecurve_type[ch] || d->basecurve_nodes != nodes)
1413+
if(d->basecurve_type != p->basecurve_type[ch] || d->basecurve_nodes != p->basecurve_nodes[ch])
14201414
{
14211415
if(d->curve) // catch initial init_pipe case
14221416
dt_draw_curve_destroy(d->curve);
14231417
d->curve = dt_draw_curve_new(0.0, 1.0, p->basecurve_type[ch]);
1424-
d->basecurve_nodes = nodes;
1418+
d->basecurve_nodes = p->basecurve_nodes[ch];
14251419
d->basecurve_type = p->basecurve_type[ch];
1426-
for(int k = 0; k < nodes; k++)
1420+
for(int k = 0; k < p->basecurve_nodes[ch]; k++)
14271421
{
14281422
// printf("p->basecurve[%i][%i].x = %f;\n", ch, k, p->basecurve[ch][k].x);
14291423
// printf("p->basecurve[%i][%i].y = %f;\n", ch, k, p->basecurve[ch][k].y);
@@ -1432,13 +1426,13 @@ void commit_params(dt_iop_module_t *self,
14321426
}
14331427
else
14341428
{
1435-
for(int k = 0; k < nodes; k++)
1429+
for(int k = 0; k < p->basecurve_nodes[ch]; k++)
14361430
dt_draw_curve_set_point(d->curve, k, p->basecurve[ch][k].x, p->basecurve[ch][k].y);
14371431
}
14381432
dt_draw_curve_calc_values(d->curve, 0.0f, 1.0f, 0x10000, NULL, d->table);
14391433

14401434
// now the extrapolation stuff:
1441-
const float xm = p->basecurve[0][MAX(1, nodes) - 1].x;
1435+
const float xm = p->basecurve[0][p->basecurve_nodes[0] - 1].x;
14421436
const float x[4] = { 0.7f * xm, 0.8f * xm, 0.9f * xm, 1.0f * xm };
14431437
const float y[4] = { d->table[CLAMP((int)(x[0] * 0x10000ul), 0, 0xffff)],
14441438
d->table[CLAMP((int)(x[1] * 0x10000ul), 0, 0xffff)],
@@ -1566,27 +1560,27 @@ static gboolean dt_iop_basecurve_draw(GtkWidget *widget, cairo_t *crf, dt_iop_mo
15661560
dt_iop_basecurve_gui_data_t *g = self->gui_data;
15671561
dt_iop_basecurve_params_t *p = self->params;
15681562

1569-
const int nodes = _basecurve_nodes(p->basecurve_nodes[0]);
1563+
int nodes = p->basecurve_nodes[0];
15701564
dt_iop_basecurve_node_t *basecurve = p->basecurve[0];
1571-
if(g->minmax_curve_type != p->basecurve_type[0] || g->minmax_curve_nodes != nodes)
1565+
if(g->minmax_curve_type != p->basecurve_type[0] || g->minmax_curve_nodes != p->basecurve_nodes[0])
15721566
{
15731567
dt_draw_curve_destroy(g->minmax_curve);
15741568
g->minmax_curve = dt_draw_curve_new(0.0, 1.0, p->basecurve_type[0]);
1575-
g->minmax_curve_nodes = nodes;
1569+
g->minmax_curve_nodes = p->basecurve_nodes[0];
15761570
g->minmax_curve_type = p->basecurve_type[0];
1577-
for(int k = 0; k < nodes; k++)
1571+
for(int k = 0; k < p->basecurve_nodes[0]; k++)
15781572
(void)dt_draw_curve_add_point(g->minmax_curve, p->basecurve[0][k].x, p->basecurve[0][k].y);
15791573
}
15801574
else
15811575
{
1582-
for(int k = 0; k < nodes; k++)
1576+
for(int k = 0; k < p->basecurve_nodes[0]; k++)
15831577
dt_draw_curve_set_point(g->minmax_curve, k, p->basecurve[0][k].x, p->basecurve[0][k].y);
15841578
}
15851579
dt_draw_curve_t *minmax_curve = g->minmax_curve;
15861580
dt_draw_curve_calc_values(minmax_curve, 0.0, 1.0, DT_IOP_TONECURVE_RES, g->draw_xs, g->draw_ys);
15871581

15881582
float unbounded_coeffs[3];
1589-
const float xm = basecurve[MAX(1, nodes) - 1].x;
1583+
const float xm = basecurve[nodes - 1].x;
15901584
{
15911585
const float x[4] = { 0.7f * xm, 0.8f * xm, 0.9f * xm, 1.0f * xm };
15921586
const float y[4] = { g->draw_ys[CLAMP((int)(x[0] * DT_IOP_TONECURVE_RES), 0, DT_IOP_TONECURVE_RES - 1)],
@@ -1620,7 +1614,7 @@ static gboolean dt_iop_basecurve_draw(GtkWidget *widget, cairo_t *crf, dt_iop_mo
16201614
cairo_fill(cr);
16211615

16221616
cairo_translate(cr, 0, height);
1623-
if(g->selected >= 0 && g->selected < nodes)
1617+
if(g->selected >= 0)
16241618
{
16251619
char text[30];
16261620
// draw information about current selected node
@@ -1676,7 +1670,7 @@ static gboolean dt_iop_basecurve_draw(GtkWidget *widget, cairo_t *crf, dt_iop_mo
16761670
// draw selected cursor
16771671
cairo_set_line_width(cr, DT_PIXEL_APPLY_DPI(1.));
16781672

1679-
if(g->selected >= 0 && g->selected < nodes)
1673+
if(g->selected >= 0)
16801674
{
16811675
cairo_set_source_rgb(cr, .9, .9, .9);
16821676
const float x = to_log(basecurve[g->selected].x, g->loglogscale),
@@ -1750,10 +1744,10 @@ static void dt_iop_basecurve_sanity_check(dt_iop_module_t *self, GtkWidget *widg
17501744
dt_iop_basecurve_params_t *p = self->params;
17511745

17521746
int ch = 0;
1753-
const int nodes = _basecurve_nodes(p->basecurve_nodes[ch]);
1747+
int nodes = p->basecurve_nodes[ch];
17541748
dt_iop_basecurve_node_t *basecurve = p->basecurve[ch];
17551749

1756-
if(g->selected < 0 || g->selected >= nodes || nodes <= 2) return;
1750+
if(nodes <= 2) return;
17571751

17581752
const float mx = basecurve[g->selected].x;
17591753

@@ -1769,7 +1763,7 @@ static void dt_iop_basecurve_sanity_check(dt_iop_module_t *self, GtkWidget *widg
17691763
basecurve[k].y = basecurve[k + 1].y;
17701764
}
17711765
g->selected = -2; // avoid re-insertion of that point immediately after this
1772-
p->basecurve_nodes[ch] = nodes - 1;
1766+
p->basecurve_nodes[ch]--;
17731767
}
17741768
}
17751769

@@ -1788,7 +1782,7 @@ static void dt_iop_basecurve_motion_notify(GtkEventControllerMotion *controller,
17881782
dt_iop_basecurve_gui_data_t *g = self->gui_data;
17891783
dt_iop_basecurve_params_t *p = self->params;
17901784
int ch = 0;
1791-
int nodes = _basecurve_nodes(p->basecurve_nodes[ch]);
1785+
int nodes = p->basecurve_nodes[ch];
17921786
dt_iop_basecurve_node_t *basecurve = p->basecurve[ch];
17931787

17941788
GtkAllocation allocation;
@@ -1804,8 +1798,6 @@ static void dt_iop_basecurve_motion_notify(GtkEventControllerMotion *controller,
18041798
const float my = 1.0f - CLAMP(g->mouse_y, 0, height) / (float)height;
18051799
const float linx = to_lin(mx, g->loglogscale), liny = to_lin(my, g->loglogscale);
18061800

1807-
if(g->selected >= nodes) g->selected = -1;
1808-
18091801
if(dt_key_modifier_state() & GDK_BUTTON1_MASK)
18101802
{
18111803
// got a vertex selected:
@@ -1825,7 +1817,6 @@ static void dt_iop_basecurve_motion_notify(GtkEventControllerMotion *controller,
18251817
else if(nodes < MAXNODES && g->selected >= -1)
18261818
{
18271819
// no vertex was close, create a new one!
1828-
p->basecurve_nodes[ch] = nodes;
18291820
g->selected = _add_node(basecurve, &p->basecurve_nodes[ch], linx, liny);
18301821
dt_dev_add_history_item_target(darktable.develop, self, TRUE, widget);
18311822
}
@@ -1865,7 +1856,7 @@ static void dt_iop_basecurve_button_press(GtkGestureSingle *gesture,
18651856
dt_iop_basecurve_gui_data_t *g = self->gui_data;
18661857

18671858
int ch = 0;
1868-
int nodes = _basecurve_nodes(p->basecurve_nodes[ch]);
1859+
int nodes = p->basecurve_nodes[ch];
18691860
dt_iop_basecurve_node_t *basecurve = p->basecurve[ch];
18701861

18711862
if(gtk_gesture_single_get_current_button(gesture) == GDK_BUTTON_PRIMARY)
@@ -1911,7 +1902,6 @@ static void dt_iop_basecurve_button_press(GtkGestureSingle *gesture,
19111902
if(curve_y >= 0.0 && curve_y <= 1.0) // never add something outside the viewport, you couldn't change it afterwards
19121903
{
19131904
// create a new node
1914-
p->basecurve_nodes[ch] = nodes;
19151905
selected = _add_node(basecurve, &p->basecurve_nodes[ch], linx, curve_y);
19161906

19171907
// maybe set the new one as being selected
@@ -1944,13 +1934,11 @@ static void dt_iop_basecurve_button_press(GtkGestureSingle *gesture,
19441934
gtk_widget_queue_draw(GTK_WIDGET(g->area));
19451935
}
19461936
}
1947-
else if(gtk_gesture_single_get_current_button(gesture) == GDK_BUTTON_SECONDARY
1948-
&& g->selected >= 0 && g->selected < nodes)
1937+
else if(gtk_gesture_single_get_current_button(gesture) == GDK_BUTTON_SECONDARY && g->selected >= 0)
19491938
{
19501939
// consume the event so it does not bubble to the module body's
19511940
// right-click handler (which opens the presets menu)
19521941
dt_gui_claim(gesture);
1953-
p->basecurve_nodes[ch] = nodes;
19541942

19551943
if(g->selected == 0 || g->selected == nodes - 1)
19561944
{
@@ -1968,7 +1956,7 @@ static void dt_iop_basecurve_button_press(GtkGestureSingle *gesture,
19681956
}
19691957
basecurve[nodes - 1].x = basecurve[nodes - 1].y = 0;
19701958
g->selected = -2; // avoid re-insertion of that point immediately after this
1971-
p->basecurve_nodes[ch] = nodes - 1;
1959+
p->basecurve_nodes[ch]--;
19721960
gtk_widget_queue_draw(GTK_WIDGET(g->area));
19731961
dt_dev_add_history_item_target(darktable.develop, self, TRUE, widget);
19741962
}
@@ -1984,8 +1972,6 @@ static gboolean _move_point_internal(dt_iop_module_t *self,
19841972
dt_iop_basecurve_gui_data_t *g = self->gui_data;
19851973

19861974
const int ch = 0;
1987-
const int nodes = _basecurve_nodes(p->basecurve_nodes[ch]);
1988-
if(g->selected < 0 || g->selected >= nodes) return FALSE;
19891975
dt_iop_basecurve_node_t *basecurve = p->basecurve[ch];
19901976

19911977
const float multiplier = dt_accel_get_speed_multiplier(widget, state);

0 commit comments

Comments
 (0)