added NULL check and memory leak fixed in libr/util/w32-sys.c

This commit is contained in:
j123123 2017-07-05 04:40:14 +03:00 committed by radare
parent 949efc35e8
commit 5df164157f

View File

@ -128,15 +128,20 @@ char *ReadFromPipe(HANDLE fh) {
int strsz = BUFSIZE+1;
str = malloc (strsz);
if (!str) {
return NULL;
}
for (;;) {
bSuccess = ReadFile (fh, chBuf, BUFSIZE, &dwRead, NULL);
if (!bSuccess || dwRead == 0) {
break;
}
if (strl+dwRead>strsz) {
char *str_tmp = str;
strsz += 4096;
str = realloc (str, strsz);
if (!str) {
free (str_tmp);
return NULL;
}
}