Coverage Report

Created: 2025-06-10 07:27

/src/ghostpdl/pdf/pdf_path.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2018-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
/* Path operations for the PDF interpreter */
17
18
#include "pdf_int.h"
19
#include "pdf_font_types.h"
20
#include "pdf_gstate.h"
21
#include "pdf_path.h"
22
#include "pdf_stack.h"
23
#include "pdf_trans.h"
24
#include "gstypes.h"
25
#include "pdf_optcontent.h"
26
#include "gspath.h"         /* For gs_moveto() and friends */
27
#include "gspaint.h"        /* For gs_fill() and friends */
28
29
typedef enum path_segment_e {
30
    pdfi_moveto_seg,
31
    pdfi_lineto_seg,
32
    pdfi_curveto_seg,
33
    pdfi_re_seg,
34
    pdfi_v_curveto_seg,
35
    pdfi_y_curveto_seg,
36
    pdfi_closepath_seg
37
} pdfi_path_segment;
38
39
static int StorePathSegment(pdf_context *ctx, pdfi_path_segment segment, double *pts)
40
28.7M
{
41
28.7M
    int size = 0;
42
43
28.7M
    switch (segment)
44
28.7M
    {
45
6.06M
        case pdfi_moveto_seg:
46
17.6M
        case pdfi_lineto_seg:
47
17.6M
            size = 2;
48
17.6M
            break;
49
3.27M
        case pdfi_re_seg:
50
3.35M
        case pdfi_v_curveto_seg:
51
3.44M
        case pdfi_y_curveto_seg:
52
3.44M
            size = 4;
53
3.44M
                break;
54
6.82M
        case pdfi_curveto_seg:
55
6.82M
            size = 6;
56
6.82M
            break;
57
889k
        case pdfi_closepath_seg:
58
889k
            break;
59
0
        default:
60
0
            return_error(gs_error_undefined);
61
0
            break;
62
28.7M
    }
63
28.7M
    if (ctx->PathSegments == NULL) {
64
6.73M
        ctx->PathSegments = (char *)gs_alloc_bytes(ctx->memory, 1024, "StorePathSegment");
65
6.73M
        if (ctx->PathSegments == NULL)
66
0
            return_error(gs_error_VMerror);
67
6.73M
        ctx->PathSegmentsCurrent = ctx->PathSegments;
68
6.73M
        ctx->PathSegmentsTop = ctx->PathSegments + 1024;
69
6.73M
    }
70
28.7M
    if (ctx->PathSegmentsCurrent == ctx->PathSegmentsTop) {
71
3.23k
        char *new_accumulator = NULL;
72
3.23k
        uint64_t old_size;
73
74
3.23k
        old_size = ctx->PathSegmentsCurrent - ctx->PathSegments;
75
3.23k
        new_accumulator = (char *)gs_alloc_bytes(ctx->memory, old_size + 1024, "StorePathSegment");
76
3.23k
        if (new_accumulator == NULL)
77
0
            return_error(gs_error_VMerror);
78
3.23k
        memcpy(new_accumulator, ctx->PathSegments, old_size);
79
3.23k
        ctx->PathSegmentsCurrent = new_accumulator + old_size;
80
3.23k
        gs_free_object(ctx->memory, ctx->PathSegments, "StorePathSegment");
81
3.23k
        ctx->PathSegments = new_accumulator;
82
3.23k
        ctx->PathSegmentsTop = ctx->PathSegments + old_size + 1024;
83
3.23k
    }
84
85
28.7M
    if (ctx->PathPts == NULL) {
86
6.73M
        ctx->PathPts = (double *)gs_alloc_bytes(ctx->memory, 4096, "StorePathSegment");
87
6.73M
        if (ctx->PathPts == NULL)
88
0
            return_error(gs_error_VMerror);
89
6.73M
        ctx->PathPtsCurrent = ctx->PathPts;
90
6.73M
        ctx->PathPtsTop = ctx->PathPts + (4096 / sizeof(double));
91
6.73M
    }
92
28.7M
    if (ctx->PathPtsCurrent + size > ctx->PathPtsTop) {
93
31.8k
        double *new_accumulator = NULL;
94
31.8k
        uint64_t old_size;
95
96
31.8k
        old_size = (char *)ctx->PathPtsCurrent - (char *)ctx->PathPts;
97
31.8k
        new_accumulator = (double *)gs_alloc_bytes(ctx->memory, old_size + 4096, "StorePathSegment");
98
31.8k
        if (new_accumulator == NULL)
99
0
            return_error(gs_error_VMerror);
100
31.8k
        memcpy(new_accumulator, ctx->PathPts, old_size);
101
31.8k
        ctx->PathPtsCurrent = new_accumulator + (old_size / sizeof(double));
102
31.8k
        gs_free_object(ctx->memory, ctx->PathPts, "StorePathSegment");
103
31.8k
        ctx->PathPts = new_accumulator;
104
31.8k
        ctx->PathPtsTop = ctx->PathPts + ((old_size + 4096) / sizeof(double));
105
31.8k
    }
106
107
28.7M
    *(ctx->PathSegmentsCurrent++) = (char)segment;
108
28.7M
    switch (segment)
109
28.7M
    {
110
6.06M
        case pdfi_moveto_seg:
111
17.6M
        case pdfi_lineto_seg:
112
17.6M
            memcpy(ctx->PathPtsCurrent, pts, 2 * sizeof(double));
113
17.6M
            ctx->PathPtsCurrent += 2;
114
17.6M
            break;
115
3.27M
        case pdfi_re_seg:
116
3.35M
        case pdfi_v_curveto_seg:
117
3.44M
        case pdfi_y_curveto_seg:
118
3.44M
            memcpy(ctx->PathPtsCurrent, pts, 4 * sizeof(double));
119
3.44M
            ctx->PathPtsCurrent += 4;
120
3.44M
            break;
121
6.82M
        case pdfi_curveto_seg:
122
6.82M
            memcpy(ctx->PathPtsCurrent, pts, 6 * sizeof(double));
123
6.82M
            ctx->PathPtsCurrent += 6;
124
6.82M
            break;
125
889k
        case pdfi_closepath_seg:
126
889k
            break;
127
28.7M
    }
128
28.7M
    return 0;
129
28.7M
}
130
131
static int ApplyStoredPath(pdf_context *ctx)
132
7.11M
{
133
7.11M
    int code = 0;
134
7.11M
    char *op = NULL;
135
7.11M
    double *dpts = NULL;
136
7.11M
    double *current;
137
138
7.11M
    if (ctx->PathSegments == NULL)
139
478k
        return 0;
140
141
6.63M
    if (ctx->PathPts == NULL) {
142
0
        code = gs_note_error(gs_error_unknownerror);
143
0
        goto error;
144
0
    }
145
146
6.63M
    if (ctx->pgs->current_point_valid) {
147
21.0k
        code = gs_newpath(ctx->pgs);
148
21.0k
        if (code < 0)
149
0
            goto error;
150
21.0k
    }
151
152
6.63M
    op = ctx->PathSegments;
153
6.63M
    dpts = ctx->PathPts;
154
6.63M
    current = dpts; /* Stop stupid compilers complaining. */
155
156
33.5M
    while (op < ctx->PathSegmentsCurrent) {
157
27.1M
        if (dpts > ctx->PathPtsCurrent) {
158
0
            code = gs_note_error(gs_error_unknownerror);
159
0
            goto error;
160
0
        }
161
162
27.1M
        switch(*op++) {
163
5.75M
            case pdfi_moveto_seg:
164
5.75M
                code = gs_moveto(ctx->pgs, dpts[0], dpts[1]);
165
5.75M
                current = dpts;
166
5.75M
                dpts+= 2;
167
5.75M
                break;
168
10.7M
            case pdfi_lineto_seg:
169
10.7M
                code = gs_lineto(ctx->pgs, dpts[0], dpts[1]);
170
10.7M
                current = dpts;
171
10.7M
                dpts+= 2;
172
10.7M
                break;
173
3.19M
            case pdfi_re_seg:
174
3.19M
                code = gs_moveto(ctx->pgs, dpts[0], dpts[1]);
175
3.19M
                if (code >= 0) {
176
3.19M
                    code = gs_rlineto(ctx->pgs, dpts[2], 0);
177
3.19M
                    if (code >= 0) {
178
3.19M
                        code = gs_rlineto(ctx->pgs, 0, dpts[3]);
179
3.19M
                        if (code >= 0) {
180
3.19M
                            code = gs_rlineto(ctx->pgs, -dpts[2], 0);
181
3.19M
                            if (code >= 0)
182
3.19M
                                code = gs_closepath(ctx->pgs);
183
3.19M
                        }
184
3.19M
                    }
185
3.19M
                }
186
3.19M
                current = dpts;
187
3.19M
                dpts+= 4;
188
3.19M
                break;
189
83.2k
            case pdfi_v_curveto_seg:
190
83.2k
                code = gs_curveto(ctx->pgs, current[0], current[1], dpts[0], dpts[1], dpts[2], dpts[3]);
191
83.2k
                current = dpts + 2;
192
83.2k
                dpts+= 4;
193
83.2k
                break;
194
88.3k
            case pdfi_y_curveto_seg:
195
88.3k
                code = gs_curveto(ctx->pgs, dpts[0], dpts[1], dpts[2], dpts[3], dpts[2], dpts[3]);
196
88.3k
                current = dpts + 2;
197
88.3k
                dpts+= 4;
198
88.3k
                break;
199
6.42M
            case pdfi_curveto_seg:
200
6.42M
                code = gs_curveto(ctx->pgs, dpts[0], dpts[1], dpts[2], dpts[3], dpts[4], dpts[5]);
201
6.42M
                current = dpts + 4;
202
6.42M
                dpts+= 6;
203
6.42M
                break;
204
819k
            case pdfi_closepath_seg:
205
819k
                code = gs_closepath(ctx->pgs);
206
819k
                break;
207
0
            default:
208
0
                code = gs_note_error(gs_error_rangecheck);
209
0
                break;
210
27.1M
        }
211
27.1M
        if (code < 0)
212
214k
            break;
213
27.1M
    }
214
215
6.63M
error:
216
6.63M
    gs_free_object(ctx->memory, ctx->PathSegments, "ApplyStoredPath");
217
6.63M
    ctx->PathSegmentsTop = ctx->PathSegmentsCurrent = ctx->PathSegments = NULL;
218
6.63M
    gs_free_object(ctx->memory, ctx->PathPts, "ApplyStoredPath");
219
6.63M
    ctx->PathPtsTop = ctx->PathPtsCurrent = ctx->PathPts = NULL;
220
6.63M
    return code;
221
6.63M
}
222
223
int pdfi_moveto (pdf_context *ctx)
224
6.84M
{
225
6.84M
    int code;
226
6.84M
    double xy[2];
227
228
6.84M
    if (ctx->text.BlockDepth != 0)
229
246k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_moveto", NULL);
230
231
6.84M
    code = pdfi_destack_reals(ctx, xy, 2);
232
6.84M
    if (code < 0)
233
779k
        return code;
234
235
6.06M
    return StorePathSegment(ctx, pdfi_moveto_seg, (double *)&xy);
236
6.84M
}
237
238
int pdfi_lineto (pdf_context *ctx)
239
12.2M
{
240
12.2M
    int code;
241
12.2M
    double xy[2];
242
243
12.2M
    if (ctx->text.BlockDepth != 0)
244
282k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_lineto", NULL);
245
246
12.2M
    code = pdfi_destack_reals(ctx, xy, 2);
247
12.2M
    if (code < 0)
248
670k
        return code;
249
250
11.5M
    return StorePathSegment(ctx, pdfi_lineto_seg, (double *)&xy);
251
12.2M
}
252
253
static int pdfi_fill_inner(pdf_context *ctx, bool use_eofill)
254
2.19M
{
255
2.19M
    int code=0, code1;
256
2.19M
    pdfi_trans_state_t state;
257
258
2.19M
    if (ctx->text.BlockDepth != 0)
259
133k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_fill_inner", NULL);
260
261
2.19M
    if (pdfi_oc_is_off(ctx))
262
59.7k
        goto exit;
263
264
2.13M
    code = ApplyStoredPath(ctx);
265
2.13M
    if (code < 0)
266
13.2k
        return code;
267
268
2.12M
    code = pdfi_trans_setup(ctx, &state, NULL, TRANSPARENCY_Caller_Fill);
269
2.12M
    if (code == 0) {
270
        /* If we don't gsave/grestore round the fill, then the file
271
         * /tests_private/pdf/sumatra/954_-_dashed_lines_hardly_visible.pdf renders
272
         * incorrectly. However we must not gsave/grestore round the trans_setup
273
         * trans_teardown, because that might set pgs->soft_mask_id and if we restore
274
         * back to a point where that is not set then pdfwrite doesn't work properly.
275
         */
276
2.12M
        code = pdfi_gsave(ctx);
277
2.12M
        if (code < 0) goto exit;
278
279
2.12M
        if (use_eofill)
280
89.3k
            code = gs_eofill(ctx->pgs);
281
2.03M
        else
282
2.03M
            code = gs_fill(ctx->pgs);
283
2.12M
        code1 = pdfi_grestore(ctx);
284
2.12M
        if (code == 0) code = code1;
285
286
2.12M
        code1 = pdfi_trans_teardown(ctx, &state);
287
2.12M
        if (code == 0) code = code1;
288
2.12M
    }
289
290
2.18M
 exit:
291
2.18M
    code1 = pdfi_newpath(ctx);
292
2.18M
    if (code == 0) code = code1;
293
294
2.18M
    return code;
295
2.12M
}
296
297
int pdfi_fill(pdf_context *ctx)
298
2.10M
{
299
2.10M
    return pdfi_fill_inner(ctx, false);
300
2.10M
}
301
302
int pdfi_eofill(pdf_context *ctx)
303
93.0k
{
304
93.0k
    return pdfi_fill_inner(ctx, true);
305
93.0k
}
306
307
int pdfi_stroke(pdf_context *ctx)
308
4.07M
{
309
4.07M
    int code=0, code1;
310
4.07M
    pdfi_trans_state_t state;
311
312
4.07M
    if (ctx->text.BlockDepth != 0)
313
268k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_stroke", NULL);
314
315
4.07M
    if (pdfi_oc_is_off(ctx))
316
51
        goto exit;
317
318
4.07M
    code = ApplyStoredPath(ctx);
319
4.07M
    if (code < 0)
320
153k
        return code;
321
322
3.92M
    gs_swapcolors_quick(ctx->pgs);
323
3.92M
    code = pdfi_trans_setup(ctx, &state, NULL, TRANSPARENCY_Caller_Stroke);
324
3.92M
    if (code == 0) {
325
3.92M
        code = pdfi_gsave(ctx);
326
3.92M
        if (code < 0) goto exit;
327
328
3.92M
        code = gs_stroke(ctx->pgs);
329
330
3.92M
        code1 = pdfi_grestore(ctx);
331
3.92M
        if (code == 0) code = code1;
332
333
3.92M
        code1 = pdfi_trans_teardown(ctx, &state);
334
3.92M
        if (code == 0) code = code1;
335
3.92M
    }
336
3.92M
    gs_swapcolors_quick(ctx->pgs);
337
338
3.92M
 exit:
339
3.92M
    code1 = pdfi_newpath(ctx);
340
3.92M
    if (code == 0) code = code1;
341
342
3.92M
    return code;
343
3.92M
}
344
345
int pdfi_closepath_stroke(pdf_context *ctx)
346
82.0k
{
347
82.0k
    int code;
348
349
82.0k
    if (ctx->text.BlockDepth != 0)
350
28.6k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_closepath_stroke", NULL);
351
352
82.0k
    code = StorePathSegment(ctx, pdfi_closepath_seg, NULL);
353
82.0k
    if (code < 0)
354
0
        return code;
355
356
82.0k
    return pdfi_stroke(ctx);
357
82.0k
}
358
359
int pdfi_curveto(pdf_context *ctx)
360
7.24M
{
361
7.24M
    int code;
362
7.24M
    double Values[6];
363
364
7.24M
    code = pdfi_destack_reals(ctx, Values, 6);
365
7.24M
    if (code < 0)
366
422k
        return code;
367
368
6.82M
    if (ctx->text.BlockDepth != 0)
369
13.2k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_curveto", NULL);
370
371
6.82M
    return StorePathSegment(ctx, pdfi_curveto_seg, (double *)&Values);
372
7.24M
}
373
374
int pdfi_v_curveto(pdf_context *ctx)
375
88.9k
{
376
88.9k
    int code;
377
88.9k
    double Values[4];
378
379
88.9k
    code = pdfi_destack_reals(ctx, Values, 4);
380
88.9k
    if (code < 0)
381
5.37k
        return code;
382
383
83.5k
    if (ctx->text.BlockDepth != 0)
384
50
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_v_curveto", NULL);
385
386
83.5k
    return StorePathSegment(ctx, pdfi_v_curveto_seg, (double *)&Values);
387
88.9k
}
388
389
int pdfi_y_curveto(pdf_context *ctx)
390
111k
{
391
111k
    int code;
392
111k
    double Values[4];
393
394
111k
    code = pdfi_destack_reals(ctx, Values, 4);
395
111k
    if (code < 0)
396
22.3k
        return code;
397
398
88.7k
    if (ctx->text.BlockDepth != 0)
399
55
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_y_curveto", NULL);
400
401
88.7k
    return StorePathSegment(ctx, pdfi_y_curveto_seg, (double *)&Values);
402
111k
}
403
404
int pdfi_closepath(pdf_context *ctx)
405
794k
{
406
794k
    if (ctx->text.BlockDepth != 0)
407
56.3k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_closepath", NULL);
408
409
794k
    return StorePathSegment(ctx, pdfi_closepath_seg, NULL);
410
794k
}
411
412
int pdfi_newpath(pdf_context *ctx)
413
7.58M
{
414
7.58M
    int code = 0, code1;
415
416
    /* This code is to deal with the wacky W and W* operators */
417
7.58M
    if (ctx->clip_active) {
418
900k
        if (ctx->PathSegments != NULL) {
419
848k
            code = ApplyStoredPath(ctx);
420
848k
            if (code < 0)
421
45.6k
                return code;
422
848k
        }
423
855k
        if (ctx->pgs->current_point_valid) {
424
800k
            if (ctx->do_eoclip)
425
55.1k
                code = gs_eoclip(ctx->pgs);
426
745k
            else
427
745k
                code = gs_clip(ctx->pgs);
428
800k
        }
429
855k
    }
430
7.54M
    ctx->clip_active = false;
431
432
7.54M
    if (ctx->PathSegments != NULL){
433
97.1k
        gs_free_object(ctx->memory, ctx->PathSegments, "ApplyStoredPath");
434
97.1k
        ctx->PathSegmentsTop = ctx->PathSegmentsCurrent = ctx->PathSegments = NULL;
435
97.1k
        gs_free_object(ctx->memory, ctx->PathPts, "ApplyStoredPath");
436
97.1k
        ctx->PathPtsTop = ctx->PathPtsCurrent = ctx->PathPts = NULL;
437
97.1k
    }
438
439
7.54M
    code1 = gs_newpath(ctx->pgs);
440
7.54M
    if (code == 0) code = code1;
441
442
7.54M
    if (ctx->text.BlockDepth != 0)
443
467k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_newpath", NULL);
444
445
7.54M
    return code;
446
7.58M
}
447
448
int pdfi_b(pdf_context *ctx)
449
12.8k
{
450
12.8k
    int code;
451
452
12.8k
    if (ctx->text.BlockDepth != 0)
453
7.61k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_b", NULL);
454
455
12.8k
    code = StorePathSegment(ctx, pdfi_closepath_seg, NULL);
456
12.8k
    if (code < 0)
457
0
        return code;
458
459
12.8k
    return pdfi_B(ctx);
460
12.8k
}
461
462
int pdfi_b_star(pdf_context *ctx)
463
432
{
464
432
    int code;
465
466
432
    if (ctx->text.BlockDepth != 0)
467
2
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_b_star", NULL);
468
469
432
    code = StorePathSegment(ctx, pdfi_closepath_seg, NULL);
470
432
    if (code < 0)
471
0
        return code;
472
473
432
    return pdfi_B_star(ctx);
474
432
}
475
476
/* common code for B and B* */
477
static int pdfi_B_inner(pdf_context *ctx, bool use_eofill)
478
56.4k
{
479
56.4k
    int code=0, code1=0;
480
56.4k
    pdfi_trans_state_t state;
481
482
56.4k
    if (ctx->text.BlockDepth != 0)
483
29.1k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_B_inner", NULL);
484
485
56.4k
    if (pdfi_oc_is_off(ctx))
486
4
        goto exit;
487
488
56.4k
    code = ApplyStoredPath(ctx);
489
56.4k
    if (code < 0)
490
2.04k
        return code;
491
492
54.3k
    code = pdfi_trans_setup(ctx, &state, NULL, TRANSPARENCY_Caller_FillStroke);
493
54.3k
    if (code == 0) {
494
54.3k
        code = pdfi_gsave(ctx);
495
54.3k
        if (code < 0) goto exit;
496
497
54.3k
        if (use_eofill)
498
2.19k
            code = gs_eofillstroke(ctx->pgs, &code1);
499
52.2k
        else
500
52.2k
            code = gs_fillstroke(ctx->pgs, &code1);
501
502
54.3k
        code1 = pdfi_grestore(ctx);
503
54.3k
        if (code == 0) code = code1;
504
505
54.3k
        code1 = pdfi_trans_teardown(ctx, &state);
506
54.3k
        if (code >= 0) code = code1;
507
54.3k
    }
508
509
54.3k
 exit:
510
54.3k
    code1 = pdfi_newpath(ctx);
511
54.3k
    if (code == 0) code = code1;
512
513
54.3k
    return code;
514
54.3k
}
515
516
int pdfi_B(pdf_context *ctx)
517
54.1k
{
518
54.1k
    return pdfi_B_inner(ctx, false);
519
54.1k
}
520
521
int pdfi_B_star(pdf_context *ctx)
522
2.30k
{
523
2.30k
    return pdfi_B_inner(ctx, true);
524
2.30k
}
525
526
int pdfi_clip(pdf_context *ctx)
527
0
{
528
0
    int code = gs_clip(ctx->pgs);
529
530
0
    if (ctx->text.BlockDepth != 0)
531
0
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_B_clip", NULL);
532
533
0
    return code;
534
0
}
535
536
int pdfi_eoclip(pdf_context *ctx)
537
0
{
538
0
    int code = gs_eoclip(ctx->pgs);
539
540
0
    if (ctx->text.BlockDepth != 0)
541
0
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_eoclip", NULL);
542
543
0
     return code;
544
0
}
545
546
int pdfi_rectpath(pdf_context *ctx)
547
3.43M
{
548
3.43M
    int code;
549
3.43M
    double Values[4];
550
551
3.43M
    code = pdfi_destack_reals(ctx, Values, 4);
552
3.43M
    if (code < 0)
553
167k
        return code;
554
555
3.27M
    if (ctx->text.BlockDepth != 0)
556
169k
        pdfi_set_warning(ctx, 0, NULL, W_PDF_OPINVALIDINTEXT, "pdfi_rectpath", NULL);
557
558
3.27M
    return StorePathSegment(ctx, pdfi_re_seg, (double *)&Values);
559
3.43M
}