Address https://github.com/catseye/Dipple/issues/2 .
Chris Pressey
5 years ago
1 | 1 | * stringie.c -- a brain-freezingly pedantic implementation of Underload in C |
2 | 2 | * (with all the limitations that that implies) |
3 | 3 | * Chris Pressey, September 2010 |
4 | * Bug fix, August 2017: avoid memory overrun in (). Thanks to @stasoid for finding and suggesting fix. | |
4 | 5 | * This work is in the public domain. |
5 | 6 | */ |
6 | 7 | |
132 | 133 | { |
133 | 134 | int level = 0; |
134 | 135 | int j = 0; |
135 | char *t = malloc(256); | |
136 | int size = 256; | |
137 | char *t = malloc(size); | |
136 | 138 | |
137 | 139 | i++; |
138 | 140 | level++; |
144 | 146 | if (level > 0) { |
145 | 147 | t[j] = program[i]; |
146 | 148 | j++; |
149 | if (j >= size) { | |
150 | size *= 2; | |
151 | t = realloc(t, size); | |
152 | } | |
147 | 153 | } |
148 | 154 | i++; |
149 | 155 | } |