]> gitweb.michael.orlitzky.com - libsvgtiny.git/commit
src/svgtiny_gradient.c: be more careful with float -> int assignment
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 8 Jun 2025 00:58:50 +0000 (20:58 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 8 Jun 2025 02:18:16 +0000 (22:18 -0400)
commitcd10e5557dfa1bcba33694501be68867d99f6e77
treed70cf6cb3d1014574e719f2e44795407db625732
parent234ba19e60a22fb540c2e9703abeae1ef527812a
src/svgtiny_gradient.c: be more careful with float -> int assignment

Assigning the value of a float to an unsigned int is undefined
behavior unless the value is guaranteed to fit. We run afoul of this
in compute_grad_points(), where the number of steps is computed using
a floating point calculation.

On a RISC-V / musl system, the end result is that we wind up with
steps = the maximum value of an unsigned int, when really this should
be an error case resulting in steps = 1. The test suite catches this.
src/svgtiny_gradient.c