All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] stk: Fix issue in stk_alpha_id_set
@ 2011-01-26 14:43 Jeevaka Badrappan
  2011-01-26 17:16 ` andrzej zaborowski
  0 siblings, 1 reply; 3+ messages in thread
From: Jeevaka Badrappan @ 2011-01-26 14:43 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

Fixes the crash seen when the null alpha identifier.
Also removed the icon check as icon will always be a
valid pointer.
---
 src/stk.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 29d2087..c968eef 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -477,9 +477,9 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
 		const char *text, const struct stk_text_attribute *attr,
 		const struct stk_icon_id *icon)
 {
-	char *alpha = dbus_apply_text_attributes(text, attr);
+	char *alpha = dbus_apply_text_attributes(text ? text : "", attr);
 
-	if (alpha || icon)
+	if (alpha != NULL && alpha[0] != '\0')
 		stk_agent_display_action_info(stk->current_agent, alpha, icon);
 
 	g_free(alpha);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] stk: Fix issue in stk_alpha_id_set
  2011-01-26 14:43 [PATCH] stk: Fix issue in stk_alpha_id_set Jeevaka Badrappan
@ 2011-01-26 17:16 ` andrzej zaborowski
  2011-01-26 17:17   ` andrzej zaborowski
  0 siblings, 1 reply; 3+ messages in thread
From: andrzej zaborowski @ 2011-01-26 17:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

Hi Jeevaka,

On 26 January 2011 15:43, Jeevaka Badrappan
<jeevaka.badrappan@elektrobit.com> wrote:
> Fixes the crash seen when the null alpha identifier.
> Also removed the icon check as icon will always be a
> valid pointer.

Good catch, but we should fix this check instead of removing it, by
using icon->id != 0.

> ---
>  src/stk.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/stk.c b/src/stk.c
> index 29d2087..c968eef 100644
> --- a/src/stk.c
> +++ b/src/stk.c
> @@ -477,9 +477,9 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
>                const char *text, const struct stk_text_attribute *attr,
>                const struct stk_icon_id *icon)
>  {
> -       char *alpha = dbus_apply_text_attributes(text, attr);
> +       char *alpha = dbus_apply_text_attributes(text ? text : "", attr);
>
> -       if (alpha || icon)
> +       if (alpha != NULL && alpha[0] != '\0')
>                stk_agent_display_action_info(stk->current_agent, alpha, icon);

Ah, now I think I know where that crash is coming from, it's because
of NULL alpha and non-NULL icon.  I think the right thing to do would
be to use alpha ? alpha : "" in the parameter.

Best regards

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] stk: Fix issue in stk_alpha_id_set
  2011-01-26 17:16 ` andrzej zaborowski
@ 2011-01-26 17:17   ` andrzej zaborowski
  0 siblings, 0 replies; 3+ messages in thread
From: andrzej zaborowski @ 2011-01-26 17:17 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]

On 26 January 2011 18:16, andrzej zaborowski <balrogg@gmail.com> wrote:
> Hi Jeevaka,
>
> On 26 January 2011 15:43, Jeevaka Badrappan
> <jeevaka.badrappan@elektrobit.com> wrote:
>> Fixes the crash seen when the null alpha identifier.
>> Also removed the icon check as icon will always be a
>> valid pointer.
>
> Good catch, but we should fix this check instead of removing it, by
> using icon->id != 0.
>
>> ---
>>  src/stk.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/stk.c b/src/stk.c
>> index 29d2087..c968eef 100644
>> --- a/src/stk.c
>> +++ b/src/stk.c
>> @@ -477,9 +477,9 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
>>                const char *text, const struct stk_text_attribute *attr,
>>                const struct stk_icon_id *icon)
>>  {
>> -       char *alpha = dbus_apply_text_attributes(text, attr);
>> +       char *alpha = dbus_apply_text_attributes(text ? text : "", attr);
>>
>> -       if (alpha || icon)
>> +       if (alpha != NULL && alpha[0] != '\0')
>>                stk_agent_display_action_info(stk->current_agent, alpha, icon);
>
> Ah, now I think I know where that crash is coming from, it's because
> of NULL alpha and non-NULL icon.  I think the right thing to do would
> be to use alpha ? alpha : "" in the parameter.

Or possibly this check should be inside stk_agent_display_action_info,
what do you think?

Best regards

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-26 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26 14:43 [PATCH] stk: Fix issue in stk_alpha_id_set Jeevaka Badrappan
2011-01-26 17:16 ` andrzej zaborowski
2011-01-26 17:17   ` andrzej zaborowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.