mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
- switched src and dest in memcpy. This caused a segm fault in hw_new_document_from_file()
This commit is contained in:
parent
90544a10ee
commit
9290bf04e8
1 changed files with 4 additions and 4 deletions
|
@ -2911,9 +2911,9 @@ PHP_FUNCTION(hw_new_document_from_file)
|
||||||
fstat(fd, &sbuf);
|
fstat(fd, &sbuf);
|
||||||
|
|
||||||
if (sbuf.st_size > BUFSIZE) {
|
if (sbuf.st_size > BUFSIZE) {
|
||||||
/* off = ftell(fp); */
|
off = ftell(fp);
|
||||||
len = sbuf.st_size;/* - off; */
|
len = sbuf.st_size - off;
|
||||||
p = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, off);
|
p = mmap(0, len, PROT_READ, MAP_SHARED, fd, off);
|
||||||
if (p != (void *) MAP_FAILED) {
|
if (p != (void *) MAP_FAILED) {
|
||||||
doc->data = malloc(len);
|
doc->data = malloc(len);
|
||||||
if(NULL == doc->data) {
|
if(NULL == doc->data) {
|
||||||
|
@ -2921,7 +2921,7 @@ PHP_FUNCTION(hw_new_document_from_file)
|
||||||
free(doc);
|
free(doc);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
memcpy(p, doc->data, len);
|
memcpy(doc->data, p, len);
|
||||||
munmap(p, len);
|
munmap(p, len);
|
||||||
bcount = len;
|
bcount = len;
|
||||||
doc->size = len;
|
doc->size = len;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue