]> O.S.I.I.S - jp/vkvg.git/commitdiff
Patch vkvg_pattern_get_color_stop_rgba and vkvg_rel_curve_to (#102)
authorMarco Rubin <20150305+Rubo3@users.noreply.github.com>
Thu, 3 Mar 2022 06:42:38 +0000 (07:42 +0100)
committerGitHub <noreply@github.com>
Thu, 3 Mar 2022 06:42:38 +0000 (07:42 +0100)
* vkvg_pattern_get_color_stop_rgba test out of bound indices
* vkvg_rel_curve_to: raise status if no current point defined

src/vkvg_context.c
src/vkvg_pattern.c

index 3a2b92a0d32b517ac4a4a2ef9aa67cc692872c20..6e5d125fe440baa6ac58cc3bb6bf37b90870eca2 100644 (file)
@@ -603,6 +603,10 @@ void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, flo
 void vkvg_rel_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) {
        if (ctx->status)
                return;
+       if (_current_path_is_empty(ctx)) {
+               ctx->status = VKVG_STATUS_NO_CURRENT_POINT;
+               return;
+       }
        RECORD(ctx, (uint32_t)VKVG_CMD_REL_CURVE_TO, x1, y1, x2, y2, x3, y3);
        LOG(VKVG_LOG_INFO_CMD, "\tCMD: rel curve_to %f,%f %f,%f %f,%f:\n", x1, y1, x2, y2, x3, y3);
        vec2 cp = _get_current_position(ctx);
index ec74d27c1d865d8e3f64d4ae2338a3a4f508b03f..ee902d45effc4d9ba9b18e14625b55f0f12cb7db 100644 (file)
@@ -173,6 +173,8 @@ vkvg_status_t vkvg_pattern_get_color_stop_rgba (VkvgPattern pat, uint32_t index,
        if (pat->type == VKVG_PATTERN_TYPE_SURFACE || pat->type == VKVG_PATTERN_TYPE_SOLID)
                return VKVG_STATUS_PATTERN_TYPE_MISMATCH;
        vkvg_gradient_t* grad = (vkvg_gradient_t*)pat->data;
+       if (index >= grad->count)
+               return VKVG_STATUS_INVALID_INDEX;
 #ifdef VKVG_VK_SCALAR_BLOCK_SUPPORTED
        *offset = grad->stops[index];
 #else