X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/f53020e729d583f7975095ca7b4b467741d99edb..6e91de5a8d1bd3c94f6bf6c80e284a374a5c7187:/client/reveng/reveng.c diff --git a/client/reveng/reveng.c b/client/reveng/reveng.c index 3c6da126..d82353f8 100644 --- a/client/reveng/reveng.c +++ b/client/reveng/reveng.c @@ -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);