6
6
* Portions Copyright (c) 1994, Regents of the University of California
7
7
*
8
8
* IDENTIFICATION
9
- * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.19 2009/01/29 19:23:39 tgl Exp $
9
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.20 2009/02/28 18:49:42 tgl Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -203,7 +203,7 @@ koi8r_to_win1251(PG_FUNCTION_ARGS)
203
203
204
204
CHECK_ENCODING_CONVERSION_ARGS (PG_KOI8R , PG_WIN1251 );
205
205
206
- buf = palloc (len * ENCODING_GROWTH_RATE );
206
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
207
207
koi8r2mic (src , buf , len );
208
208
mic2win1251 (buf , dest , strlen ((char * ) buf ));
209
209
pfree (buf );
@@ -221,7 +221,7 @@ win1251_to_koi8r(PG_FUNCTION_ARGS)
221
221
222
222
CHECK_ENCODING_CONVERSION_ARGS (PG_WIN1251 , PG_KOI8R );
223
223
224
- buf = palloc (len * ENCODING_GROWTH_RATE );
224
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
225
225
win12512mic (src , buf , len );
226
226
mic2koi8r (buf , dest , strlen ((char * ) buf ));
227
227
pfree (buf );
@@ -239,7 +239,7 @@ koi8r_to_win866(PG_FUNCTION_ARGS)
239
239
240
240
CHECK_ENCODING_CONVERSION_ARGS (PG_KOI8R , PG_WIN866 );
241
241
242
- buf = palloc (len * ENCODING_GROWTH_RATE );
242
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
243
243
koi8r2mic (src , buf , len );
244
244
mic2win866 (buf , dest , strlen ((char * ) buf ));
245
245
pfree (buf );
@@ -257,7 +257,7 @@ win866_to_koi8r(PG_FUNCTION_ARGS)
257
257
258
258
CHECK_ENCODING_CONVERSION_ARGS (PG_WIN866 , PG_KOI8R );
259
259
260
- buf = palloc (len * ENCODING_GROWTH_RATE );
260
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
261
261
win8662mic (src , buf , len );
262
262
mic2koi8r (buf , dest , strlen ((char * ) buf ));
263
263
pfree (buf );
@@ -281,7 +281,7 @@ win866_to_win1251(PG_FUNCTION_ARGS)
281
281
* not in KOI8R. As we use MULE_INTERNAL/KOI8R as an intermediary, we
282
282
* will fail to convert those characters.
283
283
*/
284
- buf = palloc (len * ENCODING_GROWTH_RATE );
284
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
285
285
win8662mic (src , buf , len );
286
286
mic2win1251 (buf , dest , strlen ((char * ) buf ));
287
287
pfree (buf );
@@ -300,7 +300,7 @@ win1251_to_win866(PG_FUNCTION_ARGS)
300
300
CHECK_ENCODING_CONVERSION_ARGS (PG_WIN1251 , PG_WIN866 );
301
301
302
302
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
303
- buf = palloc (len * ENCODING_GROWTH_RATE );
303
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
304
304
win12512mic (src , buf , len );
305
305
mic2win866 (buf , dest , strlen ((char * ) buf ));
306
306
pfree (buf );
@@ -318,7 +318,7 @@ iso_to_koi8r(PG_FUNCTION_ARGS)
318
318
319
319
CHECK_ENCODING_CONVERSION_ARGS (PG_ISO_8859_5 , PG_KOI8R );
320
320
321
- buf = palloc (len * ENCODING_GROWTH_RATE );
321
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
322
322
iso2mic (src , buf , len );
323
323
mic2koi8r (buf , dest , strlen ((char * ) buf ));
324
324
pfree (buf );
@@ -336,7 +336,7 @@ koi8r_to_iso(PG_FUNCTION_ARGS)
336
336
337
337
CHECK_ENCODING_CONVERSION_ARGS (PG_KOI8R , PG_ISO_8859_5 );
338
338
339
- buf = palloc (len * ENCODING_GROWTH_RATE );
339
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
340
340
koi8r2mic (src , buf , len );
341
341
mic2iso (buf , dest , strlen ((char * ) buf ));
342
342
pfree (buf );
@@ -355,7 +355,7 @@ iso_to_win1251(PG_FUNCTION_ARGS)
355
355
CHECK_ENCODING_CONVERSION_ARGS (PG_ISO_8859_5 , PG_WIN1251 );
356
356
357
357
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
358
- buf = palloc (len * ENCODING_GROWTH_RATE );
358
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
359
359
iso2mic (src , buf , len );
360
360
mic2win1251 (buf , dest , strlen ((char * ) buf ));
361
361
pfree (buf );
@@ -374,7 +374,7 @@ win1251_to_iso(PG_FUNCTION_ARGS)
374
374
CHECK_ENCODING_CONVERSION_ARGS (PG_WIN1251 , PG_ISO_8859_5 );
375
375
376
376
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
377
- buf = palloc (len * ENCODING_GROWTH_RATE );
377
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
378
378
win12512mic (src , buf , len );
379
379
mic2iso (buf , dest , strlen ((char * ) buf ));
380
380
pfree (buf );
@@ -393,7 +393,7 @@ iso_to_win866(PG_FUNCTION_ARGS)
393
393
CHECK_ENCODING_CONVERSION_ARGS (PG_ISO_8859_5 , PG_WIN866 );
394
394
395
395
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
396
- buf = palloc (len * ENCODING_GROWTH_RATE );
396
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
397
397
iso2mic (src , buf , len );
398
398
mic2win866 (buf , dest , strlen ((char * ) buf ));
399
399
pfree (buf );
@@ -412,7 +412,7 @@ win866_to_iso(PG_FUNCTION_ARGS)
412
412
CHECK_ENCODING_CONVERSION_ARGS (PG_WIN866 , PG_ISO_8859_5 );
413
413
414
414
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
415
- buf = palloc (len * ENCODING_GROWTH_RATE );
415
+ buf = palloc (len * ENCODING_GROWTH_RATE + 1 );
416
416
win8662mic (src , buf , len );
417
417
mic2iso (buf , dest , strlen ((char * ) buf ));
418
418
pfree (buf );
0 commit comments