diff --git a/ext/GOTCHA/src/libc_wrappers.c b/ext/GOTCHA/src/libc_wrappers.c index 30608e1bb..b9631dbd1 100644 --- a/ext/GOTCHA/src/libc_wrappers.c +++ b/ext/GOTCHA/src/libc_wrappers.c @@ -394,7 +394,7 @@ int gotcha_int_printf(int fd, const char *format, ...) { int buffer_pos = 0; int char_width, short_width, long_width, long_long_width, size_width; int num_printed = 0; - char buffer[4096]; + char buffer[4096] = {'\0'}; va_start(args, format); while (*str) { @@ -426,8 +426,8 @@ int gotcha_int_printf(int fd, const char *format, ...) { } if (*str == 'd' || *str == 'i') { - signed long val; - char numstr[64]; + signed long val = 0; + char numstr[64] = {'\0'}; if (char_width) val = (signed long)(signed char)va_arg(args, signed int); else if (short_width) @@ -444,8 +444,8 @@ int gotcha_int_printf(int fd, const char *format, ...) { add_to_buffer(numstr, fd, &buffer_pos, buffer, sizeof(buffer), &num_printed, 1); } else if (*str == 'u') { - unsigned long val; - char numstr[64]; + unsigned long val = 0; + char numstr[64] = {'\0'}; if (char_width) val = (unsigned long)(unsigned char)va_arg(args, unsigned int); else if (short_width) @@ -462,8 +462,8 @@ int gotcha_int_printf(int fd, const char *format, ...) { add_to_buffer(numstr, fd, &buffer_pos, buffer, sizeof(buffer), &num_printed, 1); } else if (*str == 'x' || *str == 'X' || *str == 'p') { - unsigned long val; - char numstr[64]; + unsigned long val = 0; + char numstr[64] = {'\0'}; if (*str != 'p') { if (char_width) val = (unsigned long)(unsigned char)va_arg(args, unsigned int); @@ -486,7 +486,7 @@ int gotcha_int_printf(int fd, const char *format, ...) { add_to_buffer(numstr, fd, &buffer_pos, buffer, sizeof(buffer), &num_printed, 1); } else if (*str == 'c') { - char cbuf[2]; + char cbuf[2] = {'\0'}; cbuf[0] = (unsigned char)va_arg(args, unsigned int); cbuf[1] = '\0'; add_to_buffer(cbuf, fd, &buffer_pos, buffer, sizeof(buffer), &num_printed, @@ -499,7 +499,7 @@ int gotcha_int_printf(int fd, const char *format, ...) { add_to_buffer("%", fd, &buffer_pos, buffer, sizeof(buffer), &num_printed, 1); } else { - char s[3]; + char s[3] = {'\0'}; s[0] = '%'; s[1] = *str; s[2] = '\0';