소스 검색

Fixes page violation when < or ? is the last character in the file and file size is a multiple of memory page size.

akozl 11 년 전
부모
커밋
9023e7b91b
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/mod_lua.inl

+ 2 - 2
src/mod_lua.inl

@@ -161,10 +161,10 @@ static int lsp(struct mg_connection *conn, const char *path,
 
 
     for (i = 0; i < len; i++) {
     for (i = 0; i < len; i++) {
         if (p[i] == '\n') lines++;
         if (p[i] == '\n') lines++;
-        if (p[i] == '<' && p[i + 1] == '?') {
+        if ((i + 1) < len && p[i] == '<' && p[i + 1] == '?') {
             for (j = i + 1; j < len ; j++) {
             for (j = i + 1; j < len ; j++) {
                 if (p[j] == '\n') lualines++;
                 if (p[j] == '\n') lualines++;
-                if (p[j] == '?' && p[j + 1] == '>') {
+                if ((j + 1) < len && p[j] == '?' && p[j + 1] == '>') {
                     mg_write(conn, p + pos, i - pos);
                     mg_write(conn, p + pos, i - pos);
 
 
                     snprintf(chunkname, sizeof(chunkname), "@%s+%i", path, lines);
                     snprintf(chunkname, sizeof(chunkname), "@%s+%i", path, lines);