qdutils: Pre-allocate initial buffer for getline().
Some frameworks override malloc() and free() but not getline().
Pre-allocating the buffer avoids heap mismatch on free().
Change-Id: I9bd934f701ad7dbc10ec2aa21967e2a626c496f4
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index 9e36980..fc5d1d0 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -149,7 +149,7 @@
// and parses and updates information accordingly.
bool MDPVersion::updateSysFsInfo() {
FILE *sysfsFd;
- size_t len = 0;
+ size_t len = PAGE_SIZE;
ssize_t read;
char *line = NULL;
char sysfsPath[255];
@@ -172,6 +172,7 @@
__FUNCTION__, sysfsPath);
return false;
} else {
+ line = (char *) malloc(len);
while((read = getline(&line, &len, sysfsFd)) != -1) {
int index=0;
char *tokens[10];
@@ -221,9 +222,8 @@
}
}
}
- free(line);
- line = NULL;
}
+ free(line);
fclose(sysfsFd);
}
ALOGD_IF(DEBUG, "%s: mMDPVersion: %d mMdpRev: %x mRGBPipes:%d,"