X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/b69adb794594cc7ea43d3aa70aab091265195abf..8b89fcae134bd1a106738a99481e9a5dea47e2c4:/client/reveng/reveng.c diff --git a/client/reveng/reveng.c b/client/reveng/reveng.c index 3c6da126..c537b631 100644 --- a/client/reveng/reveng.c +++ b/client/reveng/reveng.c @@ -1,9 +1,9 @@ /* reveng.c - * Greg Cook, 9/Apr/2015 + * Greg Cook, 24/Feb/2016 */ /* CRC RevEng, an arbitrary-precision CRC calculator and algorithm finder - * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015 Gregory Cook + * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Gregory Cook * * This file is part of CRC RevEng. * @@ -141,8 +141,10 @@ reveng(const model_t *guess, const poly_t qpoly, int rflags, int args, const pol engini(&resc, &result, guess->spoly, guess->flags, args, argpolys); requit: - if(!(result = realloc(result, ++resc * sizeof(model_t)))) + if(!(result = realloc(result, ++resc * sizeof(model_t)))) { uerror("cannot reallocate result array"); + return NULL; + } rptr = result + resc - 1; rptr->spoly = pzero; rptr->init = pzero; @@ -257,6 +259,7 @@ engini(int *resc, model_t **result, const poly_t divisor, int flags, int args, c palloc(&apoly, dlen); calini(resc, result, divisor, flags, apoly, args, argpolys); pfree(&apoly); + free(mat); return; } @@ -470,9 +473,12 @@ chkres(int *resc, model_t **result, const poly_t divisor, const poly_t init, int pfree(&xor); if(aptr != eptr) return; - if(!(*result = realloc(*result, ++*resc * sizeof(model_t)))) + *result = realloc(*result, ++*resc * sizeof(model_t)); + if (!*result) { uerror("cannot reallocate result array"); - + return; + } + rptr = *result + *resc - 1; rptr->spoly = pclone(divisor); rptr->init = pclone(init);