summaryrefslogtreecommitdiffhomepage
path: root/src/dump.c
diff options
context:
space:
mode:
authorTatsuhiko Kubo <[email protected]>2014-08-28 05:29:25 +0900
committerTatsuhiko Kubo <[email protected]>2014-08-28 05:29:25 +0900
commit7d9b5132a5bf2bc674f340798875aab3e15aeeff (patch)
treee7551183aae596a4add118d525d50d3f89a60a1f /src/dump.c
parent921798be01294f45dfcdce2133460a2e9a9f40ec (diff)
downloadmruby-7d9b5132a5bf2bc674f340798875aab3e15aeeff.tar.gz
mruby-7d9b5132a5bf2bc674f340798875aab3e15aeeff.zip
Fix error handlings for fputs().
Diffstat (limited to 'src/dump.c')
-rw-r--r--src/dump.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dump.c b/src/dump.c
index 1eff501f9..f529c4f02 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -996,13 +996,21 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, int debug_info, FILE *fp, co
return MRB_DUMP_WRITE_FAULT;
}
while (bin_idx < bin_size) {
- if (bin_idx % 16 == 0) fputs("\n", fp);
+ if (bin_idx % 16 == 0) {
+ if (fputs("\n", fp) == EOF) {
+ mrb_free(mrb, bin);
+ return MRB_DUMP_WRITE_FAULT;
+ }
+ }
if (fprintf(fp, "0x%02x,", bin[bin_idx++]) < 0) {
mrb_free(mrb, bin);
return MRB_DUMP_WRITE_FAULT;
}
}
- fputs("\n};\n", fp);
+ if (fputs("\n};\n", fp) == EOF) {
+ mrb_free(mrb, bin);
+ return MRB_DUMP_WRITE_FAULT;
+ }
}
mrb_free(mrb, bin);