summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHaegul Pyun <phg2491@gmail.com>2018-04-18 14:45:51 +0900
committerChristoph M. Becker <cmbecker69@gmx.de>2018-04-18 15:03:48 +0200
commit6653f3b53557a19f2f13e7c3eab532f98894f036 (patch)
tree2e90f077bac16c9170bb0591959506a9ee04ba27 /examples
parentd9157ebb0873aa604fd715f6e2f8a29fc6058500 (diff)
downloadlibgd-6653f3b53557a19f2f13e7c3eab532f98894f036.tar.gz
Fix #440: new_width & new_height exception handling
Since the cos range is a real number range, there is a possibility of negative numbers. - handling fabs new_width & new_height
Diffstat (limited to 'examples')
-rw-r--r--examples/copyrotated.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/copyrotated.c b/examples/copyrotated.c
index 03e493d..00a7003 100644
--- a/examples/copyrotated.c
+++ b/examples/copyrotated.c
@@ -60,9 +60,9 @@ int main(int argc, char **arg)
/* to radian */
a2 = angle * .0174532925;
- new_width = ceil(cos(a2) * gdImageSX(im)) +
+ new_width = fabs(ceil(cos(a2) * gdImageSX(im))) +
fabs(sin(a2) * gdImageSY(im));
- new_height = ceil(cos(a2) * gdImageSY(im)) +
+ new_height = fabs(ceil(cos(a2) * gdImageSY(im))) +
fabs(sin(a2) * gdImageSX(im));