do not use fixed sized buffer in mrb_bug/mrb_warn; close #287

This commit is contained in:
Yukihiro Matsumoto
2012-06-15 14:03:02 +09:00
parent 39f47c1915
commit 195d1dd685
2 changed files with 5 additions and 8 deletions
-1
View File
@@ -428,7 +428,6 @@ int mrb_block_given_p(void);
void mrb_raise(mrb_state *mrb, struct RClass *c, const char *fmt, ...);
void rb_raise(struct RClass *c, const char *fmt, ...);
void mrb_warn(const char *fmt, ...);
void mrb_warning(const char *fmt, ...);
void mrb_bug(const char *fmt, ...);
#define E_TYPE_ERROR (mrb_class_obj_get(mrb, "TypeError"))
+5 -7
View File
@@ -229,25 +229,23 @@ void
mrb_warn(const char *fmt, ...)
{
va_list args;
char buf[256];
va_start(args, fmt);
snprintf(buf, 256, "warning: %s", fmt);
printf(buf, args);
printf("warning: ");
vprintf(fmt, args);
va_end(args);
}
void
mrb_bug(const char *fmt, ...)
{
va_list args;
char buf[256];
va_start(args, fmt);
snprintf(buf, 256, "bug: %s", fmt);
printf(buf, args);
printf("bug: ");
vprintf(fmt, args);
va_end(args);
exit(EXIT_FAILURE);
}
static const char *