From 8998d7b95cddbb8a5103f753476927f9584a30b0 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sun, 19 Mar 2017 16:34:33 -0400 Subject: robot-move: prevent crash on zero-length moves --- include/grobot.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/grobot.h b/include/grobot.h index 52a7039..60796a9 100644 --- a/include/grobot.h +++ b/include/grobot.h @@ -66,7 +66,10 @@ struct _GRobotClass { /* some convenient macros */ #define G_ROBOT_POSITION_X(robot) ((robot)->x) #define G_ROBOT_POSITION_Y(robot) ((robot)->y) -#define sign(x) (x/abs(x)) + +/* this is a little weird, but 0 case doesn't actually matter + given how the code in grobot.c uses this macro... */ +#define sign(x) (x ? x/abs(x) : 0) /* normal GObject stuff */ GType g_robot_get_type(void) G_GNUC_CONST; -- cgit v1.1