@@ -394,9 +394,11 @@ namespace Sass {
394
394
DWORD dwFileLength = GetFileSize (hFile, NULL );
395
395
if (dwFileLength == INVALID_FILE_SIZE) return 0 ;
396
396
// allocate an extra byte for the null char
397
- pBuffer = (BYTE*)malloc ((dwFileLength+1 )*sizeof (BYTE));
397
+ // and another one for edge-cases in lexer
398
+ pBuffer = (BYTE*)malloc ((dwFileLength+2 )*sizeof (BYTE));
398
399
ReadFile (hFile, pBuffer, dwFileLength, &dwBytes, NULL );
399
- pBuffer[dwFileLength] = ' \0 ' ;
400
+ pBuffer[dwFileLength+0 ] = ' \0 ' ;
401
+ pBuffer[dwFileLength+1 ] = ' \0 ' ;
400
402
CloseHandle (hFile);
401
403
// just convert from unsigned char*
402
404
char * contents = (char *) pBuffer;
@@ -408,10 +410,12 @@ namespace Sass {
408
410
if (file.is_open ()) {
409
411
size_t size = file.tellg ();
410
412
// allocate an extra byte for the null char
411
- contents = (char *) malloc ((size+1 )*sizeof (char ));
413
+ // and another one for edge-cases in lexer
414
+ contents = (char *) malloc ((size+2 )*sizeof (char ));
412
415
file.seekg (0 , std::ios::beg);
413
416
file.read (contents, size);
414
- contents[size] = ' \0 ' ;
417
+ contents[size+0 ] = ' \0 ' ;
418
+ contents[size+0 ] = ' \0 ' ;
415
419
file.close ();
416
420
}
417
421
#endif
0 commit comments