Skip to content

Commit

Permalink
SAS reader: Support 16MiB page sizes
Browse files Browse the repository at this point in the history
Fixes #286
  • Loading branch information
evanmiller committed Jan 15, 2023
1 parent 5162aac commit 4827d6d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/readstat_malloc.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <stdlib.h>

#define MAX_MALLOC_SIZE 0xFFF000
/* ~16 MB. Needs to be at least 0x3FF00, i.e. the default ~4MB block size used
* in compressed SPSS (ZSAV) files. The purpose here is to prevent massive
* allocations in the event of a malformed file or a bug in the library. */
#define MAX_MALLOC_SIZE 0x1000000
/* =16 MiB. Needs to be at least 0x3FF00, i.e. the default ~4MB block size used
* in compressed SPSS (ZSAV) files. Some SAS installations use 16MiB page sizes
* by default, see https://github.com/tidyverse/haven/issues/697.
* The purpose here is to prevent massive allocations in the event of a
* malformed file or a bug in the library. */

void *readstat_malloc(size_t len) {
if (len > MAX_MALLOC_SIZE || len == 0) {
Expand Down

0 comments on commit 4827d6d

Please sign in to comment.