Fix segfault while patching dtb

This commit is contained in:
topjohnwu
2017-12-31 19:30:56 +08:00
parent d8bb3af06b
commit 2f79d0c3b3
2 changed files with 15 additions and 4 deletions

View File

@@ -72,8 +72,10 @@ int patch_verity(void **buf, uint32_t *size, int patch) {
if (patch)
patched[write] = src[read];
}
free(*buf);
*buf = patched;
if (patch) {
free(*buf);
*buf = patched;
}
return 0;
}