[patch 01/27] resource: fix integer overflow at reallocation