Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
linyacool authored Jun 20, 2018
1 parent e2a9d02 commit 9357b3e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions WebServer/HttpData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,17 +674,18 @@ AnalysisState HttpData::analysisRequest()
handleError(fd_, 404, "Not Found!");
return ANALYSIS_ERROR;
}
void *mmapRet = mmap(NULL, sbuf.st_size, PROT_READ, MAP_PRIVATE, src_fd, 0);
close(src_fd);
if (mmapRet == (void *)-1)
{
outBuffer_.clear();
handleError(fd_, 404, "Not Found!");
return ANALYSIS_ERROR;
}
void *mmapRet = mmap(NULL, sbuf.st_size, PROT_READ, MAP_PRIVATE, src_fd, 0);
close(src_fd);
if (mmapRet == (void *)-1)
{
munmap(mmapRet, sbuf.st_size);
outBuffer_.clear();
handleError(fd_, 404, "Not Found!");
return ANALYSIS_ERROR;
}
char *src_addr = static_cast<char*>(mmapRet);
outBuffer_ += string(src_addr, src_addr + sbuf.st_size);;
munmap(src_addr, sbuf.st_size);
munmap(mmapRet, sbuf.st_size);
return ANALYSIS_SUCCESS;
}
return ANALYSIS_ERROR;
Expand Down

0 comments on commit 9357b3e

Please sign in to comment.