~spidernet/algebraiC

7486aaade3a98c338fb50e7a2b354a266808b0a7 — Alessio Chiapperini 3 years ago c7774b5
Add null check to make_zero function

Protect against passing a NULL pointer to the function. Now it will
always never crash and it will return a NULL pointer if the parameter is
NULL.
1 files changed, 4 insertions(+), 2 deletions(-)

M peano/peano.c
M peano/peano.c => peano/peano.c +4 -2
@@ 16,8 16,10 @@ struct peano {
struct peano *
make_zero(struct peano *num)
{
        num->type = ZERO;
        num->data = 0;
        if (num) {
                num->type = ZERO;
                num->data = 0;
        }

        return num;
}