From: Hyoyoung Chang <hyoyoung.chang@samsung.com>

Subject: [E-devel] [patch] elm_label - bugfix at string manipulation

ear Elementary developers.

It's a elm_label bugfix.
It has two small improvements.
1. Current code can be reference null ptr.

-                  replocater = curlocater + key_len + 1;
-                  while ((*replocater != '=') && (replocater)) 
                                                             ^^^
                                                             -
         replocater++;
         
         It should be *replocater, not replocater
         
         
         2. there are two while loop to find a separate character in
string. 
I changed it from loop to strchr.



SVN revision: 57161
This commit is contained in:
Hyoyoung Chang 2011-02-19 15:39:19 +00:00 committed by Carsten Haitzler
parent c4588a97dc
commit 0a58a1d86b
1 changed files with 22 additions and 14 deletions

View File

@ -263,27 +263,35 @@ _strbuf_key_value_replace(Eina_Strbuf *srcbuf, const char *key, const char *valu
if ((starttag) && (endtag) && (tagtxtlen > key_len))
{
char *eqchar = NULL;
repbuf = eina_strbuf_new();
diffbuf = eina_strbuf_new();
eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
srcstring = eina_strbuf_string_get(repbuf);
curlocater = strstr(srcstring, key);
if (curlocater)
// key=value
// ^ : move to here
eqchar = curlocater + key_len;
if ((curlocater) && (eqchar))
{
replocater = curlocater + key_len + 1;
while ((*replocater != '=') && (replocater))
replocater++;
while ((*replocater) &&
(*replocater != ' ') &&
(*replocater != '>'))
replocater++;
if ((replocater - curlocater) > (key_len + 1))
// some case at useless many whitespaces (key =value)
// find the separator(=) position
eqchar = strchr(curlocater + key_len, '=');
if (eqchar)
{
replocater--;
eina_strbuf_append_n(diffbuf, curlocater,
replocater-curlocater);
// key=value
// ^ : move to here
replocater = eqchar + 1;
while ((*replocater) &&
(*replocater != ' ') &&
(*replocater != '>'))
replocater++;
if ((replocater - curlocater) > key_len)
eina_strbuf_append_n(diffbuf, curlocater,
replocater-curlocater);
else
insertflag = 1;
}
else
insertflag = 1;