Browse Source

- reenabled calloc instead malloc

development
Andreas Romeyke 2 months ago
parent
commit
7343d94a04
  1. 8
      src/helper/renderer/check_renderer_ansi.c
  2. 10
      src/helper/renderer/check_renderer_default.c

8
src/helper/renderer/check_renderer_ansi.c

@ -57,27 +57,25 @@ const char * renderer_ansi ( const retmsg_t * ret, short int is_quiet ) {
if (NULL == res) {
exit(could_not_allocate_memory);
}
res->buf = malloc( RENDERMAXSIZE * sizeof(char));
res->buf = calloc( RENDERMAXSIZE, sizeof(char));
if (NULL == res->buf) {
exit(could_not_allocate_memory);
}
res->bufpos = res->buf;
res->pos=0;
res->bufsize = RENDERMAXSIZE;
memset( res->buf, 0, RENDERMAXSIZE);
strbuff_t * tmp;
tmp = malloc( sizeof( strbuff_t ) );
if (NULL == tmp) {
exit(could_not_allocate_memory);
}
tmp->buf = malloc( RENDERMINSIZE * sizeof(char));
tmp->buf = calloc( RENDERMINSIZE, sizeof(char));
if (NULL == tmp->buf) {
exit(could_not_allocate_memory);
}
tmp->bufpos = tmp->buf;
tmp->pos=0;
tmp->bufsize = RENDERMINSIZE;
memset( tmp->buf, 0, RENDERMINSIZE);
const retmsg_t * startp = ret;
short int rc_is_valid = 1;
while (NULL != startp) {
@ -177,7 +175,7 @@ const char * renderer_ansi ( const retmsg_t * ret, short int is_quiet ) {
char * result_string = res->buf;
if (NULL != res) {
free(res);
}
}
return result_string;
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/

10
src/helper/renderer/check_renderer_default.c

@ -16,27 +16,25 @@ const char * renderer_default ( const retmsg_t * ret, short int is_quiet ) {
if (NULL == res) {
exit(could_not_allocate_memory);
}
res->buf = malloc( RENDERMAXSIZE * sizeof(char));
res->buf = calloc( RENDERMAXSIZE, sizeof(char));
if (NULL == res->buf) {
exit(could_not_allocate_memory);
}
res->bufpos = res->buf;
res->pos=0;
res->bufsize = RENDERMAXSIZE;
memset( res->buf, 0, RENDERMAXSIZE);
strbuff_t * tmp;
tmp = malloc( sizeof( strbuff_t ) );
if (NULL == tmp) {
exit(could_not_allocate_memory);
}
tmp->buf = malloc( RENDERMINSIZE * sizeof(char));
tmp->buf = calloc( RENDERMINSIZE, sizeof(char));
if (NULL == tmp->buf) {
exit(could_not_allocate_memory);
}
tmp->bufpos = tmp->buf;
tmp->pos=0;
tmp->bufsize = RENDERMINSIZE;
memset( tmp->buf, 0, RENDERMINSIZE);
const retmsg_t * startp = ret;
short int rc_is_valid = 1;
while (NULL != startp) {
@ -87,7 +85,7 @@ const char * renderer_default ( const retmsg_t * ret, short int is_quiet ) {
} else {
res=secstrcat(res, tmp->buf);
}
memset(tmp->buf, 0, tmp->bufsize);
memset(tmp->buf, 0, tmp->bufsize);
tmp->bufpos= tmp->buf;
tmp->pos = 0;
rc_is_valid =1;
@ -117,7 +115,7 @@ const char * renderer_default ( const retmsg_t * ret, short int is_quiet ) {
char * result_string = res->buf;
if (NULL != res) {
free(res);
}
}
return result_string;
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/
Loading…
Cancel
Save