diff options
| author | mirichi <[email protected]> | 2013-06-22 08:06:48 +0900 |
|---|---|---|
| committer | mirichi <[email protected]> | 2013-06-22 08:06:48 +0900 |
| commit | a01845b502a902ee1de2f34645177e64fafbb551 (patch) | |
| tree | 86d9a57bc44974d111dabb5e46d4f3e89ffe026d /src/load.c | |
| parent | a5f63e486473595d67601851f00b6bb96b377a8d (diff) | |
| parent | 8cb730ae4e63a953819023a2e31265d758b9fe42 (diff) | |
| download | mruby-a01845b502a902ee1de2f34645177e64fafbb551.tar.gz mruby-a01845b502a902ee1de2f34645177e64fafbb551.zip | |
Merge remote-tracking branch 'remotes/mruby/master'
Diffstat (limited to 'src/load.c')
| -rw-r--r-- | src/load.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/load.c b/src/load.c index 62010e425..e832de628 100644 --- a/src/load.c +++ b/src/load.c @@ -539,7 +539,9 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp) size_t sirep; struct rite_section_header section_header; long fpos; - const size_t block_size = 1 << 14; + size_t block_size = 1 << 14; + const uint8_t block_fallback_count = 4; + int i; const size_t buf_size = sizeof(struct rite_binary_header); if ((mrb == NULL) || (fp == NULL)) { @@ -564,7 +566,10 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp) /* verify CRC */ fpos = ftell(fp); /* You don't need use SIZE_ERROR as block_size is enough small. */ - buf = mrb_malloc(mrb, block_size); + for (i = 0; i < block_fallback_count; i++,block_size >>= 1){ + buf = mrb_malloc(mrb, block_size); + if (buf) break; + } if (!buf) { return MRB_DUMP_GENERAL_FAILURE; } |
