summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMythri Alle <mythria@google.com>2023-01-25 13:38:32 +0000
committerMythri Alle <mythria@google.com>2023-01-25 13:42:04 +0000
commiteaf83c4418b00909263da9dc9b273eafe2be7fd1 (patch)
tree73eb518861d418afcea38b8da874b549da1c8034
parent76cdbd342102dcada250884df5f8c93a45a46608 (diff)
downloaddalvik-eaf83c4418b00909263da9dc9b273eafe2be7fd1.tar.gz
Exit early if ensureCapacity is unable to allocate the required capacity
ensureCapacity used to return -1 when the allocation failed for the requested capacity. The callers weren't checking for the return value and continued using the buffer assuming the request was successful. Since there is no way to recover from this error just exit early in ensureCapacity. Bug: 261385338 Change-Id: I75f4503ae42e6f03f8cfebb1fd3c8ee6c873c5b6
-rw-r--r--tools/hprof-conv/HprofConv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/hprof-conv/HprofConv.c b/tools/hprof-conv/HprofConv.c
index c8847c944..ff49428af 100644
--- a/tools/hprof-conv/HprofConv.c
+++ b/tools/hprof-conv/HprofConv.c
@@ -182,7 +182,7 @@ static int ebEnsureCapacity(ExpandBuf* pBuf, int size)
unsigned char* newStorage = realloc(pBuf->storage, newSize);
if (newStorage == NULL) {
fprintf(stderr, "ERROR: realloc failed on size=%d\n", newSize);
- return -1;
+ exit(1);
}
pBuf->storage = newStorage;