From: Marco Rubin <20150305+Rubo3@users.noreply.github.com> Date: Thu, 3 Mar 2022 06:42:38 +0000 (+0100) Subject: Patch vkvg_pattern_get_color_stop_rgba and vkvg_rel_curve_to (#102) X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=f1b4978ab243c9742fad3ab697d4a948ecdf0fdd;p=jp%2Fvkvg.git Patch vkvg_pattern_get_color_stop_rgba and vkvg_rel_curve_to (#102) * vkvg_pattern_get_color_stop_rgba test out of bound indices * vkvg_rel_curve_to: raise status if no current point defined --- diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 3a2b92a..6e5d125 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -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); diff --git a/src/vkvg_pattern.c b/src/vkvg_pattern.c index ec74d27..ee902d4 100644 --- a/src/vkvg_pattern.c +++ b/src/vkvg_pattern.c @@ -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