[Openais] Fix for crash when environment variable list is empty

Hans Feldt Hans.Feldt at ericsson.com
Mon Sep 4 00:46:31 PDT 2006


Thanks!

Please send patches as attachments, easier and faster to apply.

Regards,
Hans

Ola Lundqvist wrote:
> Hi
> 
> The following patch fix a problem that I had. aisexec crashed
> unexpectedly when starting up. I found that I had set no environment
> variables to be sent to the component. I assume that is a valid case so
> here is the fix.
> 
> It is simply a check if component->saAmfCompCmdEnv is NULL and if so, do
> not loop around it.
> 
> --- exec/amfcomp.c      (revision 1235)
> +++ exec/amfcomp.c      (working copy)
> @@ -1854,14 +1854,16 @@
>                 buf, &size, &offset, component->saAmfCompNumMaxStandbyCsi);
> 
>         /* count environment vars and write to buf */
> -       for (i = 0; component->saAmfCompCmdEnv[i] != NULL; i++);
> +        if (component->saAmfCompCmdEnv != NULL) {
> +            for (i = 0; component->saAmfCompCmdEnv[i] != NULL; i++);
> +        }
>         buf = amf_serialize_SaUint32T (buf, &size, &offset, i);
> -
> -       for (i = 0; component->saAmfCompCmdEnv[i] != NULL; i++) {
> +        if (component->saAmfCompCmdEnv != NULL) {
> +            for (i = 0; component->saAmfCompCmdEnv[i] != NULL; i++) {
>                 buf = amf_serialize_SaStringT (
> -                       buf, &size, &offset, component->saAmfCompCmdEnv[i]);
> -       }
> -
> +                    buf, &size, &offset, component->saAmfCompCmdEnv[i]);
> +            }
> +        }
>         buf = amf_serialize_SaUint32T (
>                 buf, &size, &offset,
> component->saAmfCompDefaultClcCliTimeout);
>         buf = amf_serialize_SaUint32T (
> 
> Best regards,
> 
> // Ola
> 




More information about the Openais mailing list