| 2817 | } |
| 2818 | #else |
| 2819 | static bool getCode(int po, int rlc, long long &c, int &lc, const char *&in, |
| 2820 | const char *in_end, unsigned short *&out, |
| 2821 | const unsigned short *ob, const unsigned short *oe) { |
| 2822 | (void)ob; |
| 2823 | if (po == rlc) { |
| 2824 | if (lc < 8) { |
| 2825 | /* TinyEXR issue 78 */ |
| 2826 | /* TinyEXR issue 160. in + 1 -> in */ |
| 2827 | if (in >= in_end) { |
| 2828 | return false; |
| 2829 | } |
| 2830 | |
| 2831 | getChar(c, lc, in); |
| 2832 | } |
| 2833 | |
| 2834 | lc -= 8; |
| 2835 | |
| 2836 | unsigned char cs = (c >> lc); |
| 2837 | |
| 2838 | if (out + cs > oe) return false; |
| 2839 | |
| 2840 | // Bounds check for safety |
| 2841 | // Issue 100. |
| 2842 | if ((out - 1) < ob) return false; |
| 2843 | unsigned short s = out[-1]; |
| 2844 | |
| 2845 | while (cs-- > 0) *out++ = s; |
| 2846 | } else if (out < oe) { |
| 2847 | *out++ = po; |
| 2848 | } else { |
| 2849 | return false; |
| 2850 | } |
| 2851 | return true; |
| 2852 | } |
| 2853 | #endif |
| 2854 | |
| 2855 | // |