Skip to content

Commit df74739

Browse files
committed
Update CONTRIBUTING.md
1 parent 98ad8c9 commit df74739

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ These must be followed, otherwise you must be prepared to defend your choices:
3434
- Do not assume GhostScript-only execution. Assume modern implementation limit, and warn when approaching those limits:
3535
- Integer representation may be 32- or 64-bit. Do not assume overflow or promotion at 32-bit.
3636
- Maximum of 65535 entries within dictionaries, arrays, and on the stack. (Assume user might already have entries on the stack.)
37-
- Maximum string length is 65535 characters.
37+
- Maximum string length of 65535 characters. Maximum name length of 127 characters.
38+
- Where an allocation could exceed these limits, wrap it with a `stopped` guard (see Implementation Limit Guards below).
3839
- Tests should be extended to cover any error conditions raised by new code.
3940

4041

@@ -398,6 +399,24 @@ barcode options //innerencoder exec /args exch def
398399
```
399400

400401

402+
### Implementation Limit Guards
403+
404+
When an encoder's input can cause an internal allocation (string, array or
405+
dictionary) to exceed the guaranteed PostScript implementation limits, the
406+
allocation must be wrapped with `stopped` to catch the error gracefully.
407+
GhostScript has higher limits so these guards may only trigger on other
408+
interpreters.
409+
410+
The guard must pop the failed size operand left on the stack by `stopped` and
411+
raise a descriptive error:
412+
413+
```postscript
414+
barcode length 8 mul { string } stopped {
415+
pop /bwipp.encoderInputTooLarge (Input data exceeds implementation limits) //raiseerror exec
416+
} if /bits exch def
417+
```
418+
419+
401420
## User API
402421

403422
```postscript

0 commit comments

Comments
 (0)