Fixed a crash in i18n character set conversion

This commit is contained in:
Klaus Schmidinger 2007-06-15 13:01:18 +02:00
parent 3224fffe87
commit 1f7c70cd49
4 changed files with 10 additions and 5 deletions

View File

@ -1841,6 +1841,7 @@ Christian Wieninger <cwieninger@gmx.de>
from the "Schedule" menu in case it starts withing the next two minutes from the "Schedule" menu in case it starts withing the next two minutes
for reporting a problem with a format string in recording.c on 64bit systems for reporting a problem with a format string in recording.c on 64bit systems
for reporting a problem with the device selection in case of timer conflicts for reporting a problem with the device selection in case of timer conflicts
for a patch that fixed part of a crash in i18n character set conversion
Thiemo Gehrke <tgehrke@reel-multimedia.com> Thiemo Gehrke <tgehrke@reel-multimedia.com>
for suggesting to add a setup option to turn off the automatic timeout of the for suggesting to add a setup option to turn off the automatic timeout of the
@ -2087,3 +2088,4 @@ Krzysztof Parma <krzycho@zoz.wodzislaw.pl>
Alexander Riedel <alexander-riedel@t-online.de> Alexander Riedel <alexander-riedel@t-online.de>
for a patch that was used as a base to implement support for Freetype fonts and for a patch that was used as a base to implement support for Freetype fonts and
UTF-8 handling UTF-8 handling
for a patch that fixed part of a crash in i18n character set conversion

View File

@ -5233,3 +5233,5 @@ Video Disk Recorder Revision History
2007-06-15: Version 1.5.4 2007-06-15: Version 1.5.4
- Increased APIVERSION (forgot to do that in 1.5.2 and 1.5.3). - Increased APIVERSION (forgot to do that in 1.5.2 and 1.5.3).
- Fixed a crash in i18n character set conversion (thanks to Alexander Riedel and
Christian Wieninger for patches that cured part of the problem).

7
i18n.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: i18n.c 1.294 2007/06/09 08:44:54 kls Exp $ * $Id: i18n.c 1.295 2007/06/15 12:52:51 kls Exp $
* *
* Translations provided by: * Translations provided by:
* *
@ -6820,7 +6820,7 @@ static const char *ConvertPhrase(const tI18nPhrase *Original, tI18nPhrase **Conv
*Converted = new tI18nPhrase[NumPhrases + 1]; *Converted = new tI18nPhrase[NumPhrases + 1];
memset(*Converted, 0, sizeof(tI18nPhrase) * (NumPhrases + 1)); memset(*Converted, 0, sizeof(tI18nPhrase) * (NumPhrases + 1));
} }
if (!(*Converted)[NrPhrase][NrLanguage]) { if (!(*Converted)[NrPhrase][NrLanguage] && Original[NrPhrase][NrLanguage]) {
cCharSetConv csc(Phrases[1][NrLanguage], cCharSetConv::SystemCharacterTable()); cCharSetConv csc(Phrases[1][NrLanguage], cCharSetConv::SystemCharacterTable());
(*Converted)[NrPhrase][NrLanguage] = strdup(csc.Convert(Original[NrPhrase][NrLanguage])); (*Converted)[NrPhrase][NrLanguage] = strdup(csc.Convert(Original[NrPhrase][NrLanguage]));
} }
@ -6851,7 +6851,8 @@ const char *I18nTranslate(const char *s, const char *Plugin)
return t; return t;
} }
} }
p = Phrases; p = OriginalPhrases = Phrases;
ConvertedPhrases = &Converted;
} }
esyslog("%s%sno translation found for '%s' in language %d (%s)", Plugin ? Plugin : "", Plugin ? ": " : "", s, Setup.OSDLanguage, Phrases[0][Setup.OSDLanguage]); esyslog("%s%sno translation found for '%s' in language %d (%s)", Plugin ? Plugin : "", Plugin ? ": " : "", s, Setup.OSDLanguage, Phrases[0][Setup.OSDLanguage]);
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.c 1.124 2007/06/15 12:20:40 kls Exp $ * $Id: tools.c 1.125 2007/06/15 12:46:38 kls Exp $
*/ */
#include "tools.h" #include "tools.h"
@ -753,7 +753,7 @@ void cCharSetConv::SetSystemCharacterTable(const char *CharacterTable)
const char *cCharSetConv::Convert(const char *From, char *To, size_t ToLength) const char *cCharSetConv::Convert(const char *From, char *To, size_t ToLength)
{ {
if (cd != (iconv_t)-1) { if (cd != (iconv_t)-1 && From && *From) {
char *FromPtr = (char *)From; char *FromPtr = (char *)From;
size_t FromLength = strlen(From); size_t FromLength = strlen(From);
char *ToPtr = To; char *ToPtr = To;