[liblouis-liblouisxml] Re: [liblouis] r1162 committed - Fix a warning

  • From: Christian Egli <christian.egli@xxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Tue, 06 May 2014 16:51:03 +0200

Hi Michael

There's something that I don't understand about a commit of yours (when
you fixed some warnings)

liblouis@xxxxxxxxxxxxxx writes:

> Log:      Fix a warning
> http://code.google.com/p/liblouis/source/detail?r=1162

> =======================================
> --- /trunk/liblouis/compileTranslationTable.c Tue Apr 29 15:22:19 2014 UTC
> +++ /trunk/liblouis/compileTranslationTable.c Tue May  6 08:23:50 2014 UTC
> @@ -5165,7 +5165,13 @@
>
>  static void defaultLogCallback(int level, const char *message)
>  {
> -  lou_logPrint(message);
> +  char *tmpMsg = malloc(strlen(message)+1);
> +  if (tmpMsg)
> +    {
> +      strcpy(tmpMsg, message);
> +      lou_logPrint(message);
> +      free(tmpMsg);
> +    }
>  }

Why do you need to copy the string before sending it to lou_logPrint?
And if you do need to copy couldn't you use strdup?

Thanks
Christian

-- 
Christian Egli
Swiss Library for the Blind, Visually Impaired and Print Disabled
Grubenstrasse 12, CH-8045 Zürich, Switzerland

-----
Tag der offenen Tuer.
Die SBS laedt Sie herzlich ein: 28. Juni 2014 von 9 bis 16 Uhr.
Mehr Informationen erhalten Sie unter http://www.sbs.ch/offenetuer
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts: