Fix a bunch of small system/core bugs.

Missing frees in:
  adb/file_sync_client.c
  fastboot/fastboot.c
  libsparse/output_file.c

Missing closedirs in:
  adb/file_sync_service.c
  cpio/mkbootfs.c
  libcutils/dir_hash.c

Potential buffer overrun in:
  gpttool/gpttool.c

Incorrect NULL check in:
  libsparse/backed_block.c

Bug: https://code.google.com/p/android/issues/detail?id=61564
Change-Id: If97838a9e73a77aef7f416c31c237ce1fca4ce21
system: core: increase the polling time for remount_ro

eMMC4.5 introduces an addition of cache on the device.
We experienced long flush durations in some of the devices,
and therefore the adb reboot resets the target before the flush
completes.

CRs-Fixed: 562350
Change-Id: I3f54901e12ffd232a7696dadfde1edec99ef91c6
system: core: increase the polling time for remount_ro to 3600

eMMC4.5 introduces an addition of cache on the device.
We experienced long flush durations in some of the devices,
and therefore the adb reboot resets the target before the flush
completes.
Latest tests show that increasing it to 2400 wasn't enough thus
it was increased to 3600.

Change-Id: Ifbe7af16aa1861d0d57c808b0240361c0317d5c5
CRs-fixed: 581363
fix corruption in Vector<> when malloc falied

1. When alloc or realloc failed in the function SharedBuffer::editResize,
it would return a NULL pointer, then mStorage would update to be 1 by
SharedBuffer::data() if no pointer check here, which is an obviously
wrong address, and would cause corruption when used it e.g. in capacity().

So add the pointer check here for the return value of SharedBuffer::editResize,
if it's NULL do not use it to update mStorage, to avoid the value of mStorage
polluted.

2. when alloc or realloc falied in _grow & _shrink function, mStorage keep
the original value, so mCount should not be updated here.

Otherwise, mStorage might be 0 but mCount>0, so a corruption would happend
when it try to delete items from the Vector since mCount>0.

Change-Id: I7c3814e843c459834ca5eed392e8d63d1cb7d2d8
Signed-off-by: Shuo Gao <shuo.gao@intel.com>
Signed-off-by: Jian Luo <jian.luo@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 139626
Fix assertion failure

Adding 0 items to vector causes assertion failure in _grow -> itemLocation

Change-Id: Ief232a9c12e2e43ee6c87a7a137fe8a94aa741d4