Open hprof files with O_TRUNC to avoid partial overwrites of existing files
Change-Id: I97a89071ad766005bb9f91661185dd901a35ae03
diff --git a/vm/hprof/Hprof.c b/vm/hprof/Hprof.c
index bcad8b1..28f81c7 100644
--- a/vm/hprof/Hprof.c
+++ b/vm/hprof/Hprof.c
@@ -131,7 +131,7 @@
/* continue to fail-handler below */
}
} else {
- outFd = open(tailCtx->fileName, O_WRONLY|O_CREAT, 0644);
+ outFd = open(tailCtx->fileName, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (outFd < 0) {
LOGE("can't open %s: %s\n", headCtx->fileName, strerror(errno));
/* continue to fail-handler below */