diff options
| author | Karl Heuer | 1998-12-16 06:32:39 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-12-16 06:32:39 +0000 |
| commit | 8c2176454014c4e6a1dba11ac9580d0d9be7a2a1 (patch) | |
| tree | b307f1b220d57b169a56af92b4cb1e5ab71b2c86 /src | |
| parent | 2e9537e74bff3127c10d0de02165527784ffd8da (diff) | |
| download | emacs-8c2176454014c4e6a1dba11ac9580d0d9be7a2a1.tar.gz emacs-8c2176454014c4e6a1dba11ac9580d0d9be7a2a1.zip | |
(Fbase64_decode_region, Fbase64_decode_string):
Do free malloc'd memory even in case of failure.
Use xfree, not free.
(Fbase64_encode_region, Fbase64_encode_string):
Use xfree, not free.
(base64_decode_1): Don't fail for short lines.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 24 |
1 files changed, 14 insertions, 10 deletions
| @@ -2859,7 +2859,7 @@ into shorter lines.") | |||
| 2859 | SET_PT_BOTH (XFASTINT (beg), ibeg); | 2859 | SET_PT_BOTH (XFASTINT (beg), ibeg); |
| 2860 | insert (encoded, encoded_length); | 2860 | insert (encoded, encoded_length); |
| 2861 | if (allength > MAX_ALLOCA) | 2861 | if (allength > MAX_ALLOCA) |
| 2862 | free (encoded); | 2862 | xfree (encoded); |
| 2863 | del_range_byte (ibeg + encoded_length, iend + encoded_length, 1); | 2863 | del_range_byte (ibeg + encoded_length, iend + encoded_length, 1); |
| 2864 | 2864 | ||
| 2865 | /* If point was outside of the region, restore it exactly; else just | 2865 | /* If point was outside of the region, restore it exactly; else just |
| @@ -2902,7 +2902,7 @@ DEFUN ("base64-encode-string", Fbase64_encode_string, Sbase64_encode_string, | |||
| 2902 | 2902 | ||
| 2903 | encoded_string = make_unibyte_string (encoded, encoded_length); | 2903 | encoded_string = make_unibyte_string (encoded, encoded_length); |
| 2904 | if (allength > MAX_ALLOCA) | 2904 | if (allength > MAX_ALLOCA) |
| 2905 | free (encoded); | 2905 | xfree (encoded); |
| 2906 | 2906 | ||
| 2907 | return encoded_string; | 2907 | return encoded_string; |
| 2908 | } | 2908 | } |
| @@ -3013,8 +3013,12 @@ If the region can't be decoded, return nil and don't modify the buffer.") | |||
| 3013 | abort (); | 3013 | abort (); |
| 3014 | 3014 | ||
| 3015 | if (decoded_length < 0) | 3015 | if (decoded_length < 0) |
| 3016 | /* The decoding wasn't possible. */ | 3016 | { |
| 3017 | return Qnil; | 3017 | /* The decoding wasn't possible. */ |
| 3018 | if (length > MAX_ALLOCA) | ||
| 3019 | xfree (decoded); | ||
| 3020 | return Qnil; | ||
| 3021 | } | ||
| 3018 | 3022 | ||
| 3019 | /* Now we have decoded the region, so we insert the new contents | 3023 | /* Now we have decoded the region, so we insert the new contents |
| 3020 | and delete the old. (Insert first in order to preserve markers.) */ | 3024 | and delete the old. (Insert first in order to preserve markers.) */ |
| @@ -3027,7 +3031,7 @@ If the region can't be decoded, return nil and don't modify the buffer.") | |||
| 3027 | insert (decoded, decoded_length); | 3031 | insert (decoded, decoded_length); |
| 3028 | inserted_chars = PT - (XFASTINT (beg) + 1); | 3032 | inserted_chars = PT - (XFASTINT (beg) + 1); |
| 3029 | if (length > MAX_ALLOCA) | 3033 | if (length > MAX_ALLOCA) |
| 3030 | free (decoded); | 3034 | xfree (decoded); |
| 3031 | /* At first delete the original text. This never cause byte | 3035 | /* At first delete the original text. This never cause byte |
| 3032 | combining. */ | 3036 | combining. */ |
| 3033 | del_range_both (PT + 1, PT_BYTE + 1, XFASTINT (end) + inserted_chars + 2, | 3037 | del_range_both (PT + 1, PT_BYTE + 1, XFASTINT (end) + inserted_chars + 2, |
| @@ -3073,11 +3077,13 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, | |||
| 3073 | abort (); | 3077 | abort (); |
| 3074 | 3078 | ||
| 3075 | if (decoded_length < 0) | 3079 | if (decoded_length < 0) |
| 3076 | return Qnil; | 3080 | /* The decoding wasn't possible. */ |
| 3081 | decoded_string = Qnil; | ||
| 3082 | else | ||
| 3083 | decoded_string = make_string (decoded, decoded_length); | ||
| 3077 | 3084 | ||
| 3078 | decoded_string = make_string (decoded, decoded_length); | ||
| 3079 | if (length > MAX_ALLOCA) | 3085 | if (length > MAX_ALLOCA) |
| 3080 | free (decoded); | 3086 | xfree (decoded); |
| 3081 | 3087 | ||
| 3082 | return decoded_string; | 3088 | return decoded_string; |
| 3083 | } | 3089 | } |
| @@ -3105,8 +3111,6 @@ base64_decode_1 (from, to, length) | |||
| 3105 | c = from[i++]; | 3111 | c = from[i++]; |
| 3106 | if (i == length) | 3112 | if (i == length) |
| 3107 | break; | 3113 | break; |
| 3108 | if (counter != MIME_LINE_LENGTH / 4) | ||
| 3109 | return -1; | ||
| 3110 | counter = 1; | 3114 | counter = 1; |
| 3111 | } | 3115 | } |
| 3112 | else | 3116 | else |