Include checks for mmap() returning NULL

This commit is contained in:
Marcel Holtmann 2005-11-09 00:04:15 +00:00
parent 118f08c948
commit db17652952
3 changed files with 4 additions and 4 deletions

View File

@ -149,7 +149,7 @@ int textfile_put(char *pathname, char *key, char *value)
}
map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, fd, 0);
if (map == MAP_FAILED) {
if (!map || map == MAP_FAILED) {
err = errno;
goto unlock;
}
@ -243,7 +243,7 @@ char *textfile_get(char *pathname, char *key)
size = st.st_size;
map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (map == MAP_FAILED) {
if (!map || map == MAP_FAILED) {
err = errno;
goto unlock;
}

View File

@ -2697,7 +2697,7 @@ int psr_read(const char *filename)
}
map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (map == MAP_FAILED) {
if (!map || map == MAP_FAILED) {
err = -errno;
goto close;
}

View File

@ -65,7 +65,7 @@ char *ouitocomp(const char *oui)
memset(str, 0, 128);
map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (map == MAP_FAILED) {
if (!map || map == MAP_FAILED) {
free(str);
close(fd);
return NULL;