WINGs: Removed checks for code that can't fail

In the function 'wdefaultspathfordomain' there was a check to make sure the
generated path would fit in the allocated area, but this allocated area is
sized precisely to fit the path, so it cannot fail.

In the function 'getCurrentFileName' there were checks to make sure the
generated result string would fit in the allocated area, but this allocated
area is sized precisely to fit the path, so it cannot fail.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS authored and Carlos R. Mafra committed 2014-05-09 20:42:34 +01:00
1 parent 546c148ac0
commit 51ad8b7dc1
2 files changed
+7 -19

No files matched your search

+4 -7
View File
@@ -90,13 +90,10 @@ char *wdefaultspathfordomain(const char *domain)
slen = strlen(gspath) + strlen(DEFAULTS_DIR) + strlen(domain) + 4;
path = wmalloc(slen);
if (wstrlcpy(path, gspath, slen) >= slen ||
wstrlcat(path, DEFAULTS_DIR, slen) >= slen ||
wstrlcat(path, "/", slen) >= slen ||
wstrlcat(path, domain, slen) >= slen) {
wfree(path);
return NULL;
}
strcpy(path, gspath);
strcat(path, DEFAULTS_DIR);
strcat(path, "/");
strcat(path, domain);
return path;
}
+3 -12
View File
@@ -823,23 +823,14 @@ static char *getCurrentFileName(WMFilePanel * panel)
slen = strlen(path) + strlen(file) + 1;
ret = wmalloc(slen);
if (*file != '/' &&
wstrlcat(ret, path, slen) >= slen)
goto error;
if (file[0] != '/')
strcpy(ret, path);
if (wstrlcat(ret, file, slen) >= slen)
goto error;
strcat(ret, file);
wfree(file);
wfree(path);
return ret;
error:
wfree(file);
wfree(path);
wfree(ret);
return NULL;
}