Re: [MM] [PATCH] port-probe: fix crash in serial_probe_at_parse_response due to NULL response



Is it safe to assume that response processor(s) can handle NULL gchar*? I guess we need to check that in response processors as well.


On Wed, Jul 11, 2012 at 11:58 PM, Aleksander Morgado <aleksander lanedo com> wrote:

> When the serial port is not open, internal_queue_command
> (mm-serial-port.c) invokes serial_probe_at_parse_response
> (mm-port-probe.c) with a NULL response. This patch modifies
> serial_probe_at_parse_response to handle that properly.
> ---
>  src/mm-port-probe.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
> index baadee0..c31affe 100644
> --- a/src/mm-port-probe.c
> +++ b/src/mm-port-probe.c
> @@ -450,7 +450,7 @@ serial_probe_at_parse_response (MMAtSerialPort *port,
>      }
>
>      if (!task->at_commands->response_processor (task->at_commands->command,
> -                                                response->str,
> +                                                (response) ? response->str : "",
>                                                  !!task->at_commands[1].command,
>                                                  error,
>                                                  &result,

When we get the NULL response, we should also get a proper 'error' set
as well. If so, the fix should be this one instead:
    response ? response->str : NULL
so that we pass NULL to the response processor instead of the empty string.

--
Aleksander





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]