mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
do not use fixed sized buffer in mrb_bug/mrb_warn; close #287
This commit is contained in:
@@ -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
@@ -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 *
|
||||
|
||||
Reference in New Issue
Block a user