Browse Source

MappedFile: Fix misuse of StringView::characters().

This makes me wonder if the open() syscall should take characters+length
and we'd compute the length at the LibC layer instead. That way we could
also provide an optional non-POSIX open() that takes the length directly..
Andreas Kling 6 years ago
parent
commit
c79b048198
1 changed files with 2 additions and 1 deletions
  1. 2 1
      AK/MappedFile.cpp

+ 2 - 1
AK/MappedFile.cpp

@@ -1,3 +1,4 @@
+#include <AK/AKString.h>
 #include <AK/MappedFile.h>
 #include <AK/MappedFile.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdio.h>
@@ -12,7 +13,7 @@ namespace AK {
 MappedFile::MappedFile(const StringView& file_name)
 MappedFile::MappedFile(const StringView& file_name)
 {
 {
     m_size = PAGE_SIZE;
     m_size = PAGE_SIZE;
-    m_fd = open(file_name.characters(), O_RDONLY | O_CLOEXEC);
+    m_fd = open(String(file_name).characters(), O_RDONLY | O_CLOEXEC);
 
 
     if (m_fd != -1) {
     if (m_fd != -1) {
         struct stat st;
         struct stat st;