Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_entry.c Log Message: Safeguard some string manipulation with NULL checks, these conditions were not possible before, but are since switching to the textblock. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_entry.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- ewl_entry.c 13 May 2005 03:26:13 -0000 1.15 +++ ewl_entry.c 24 May 2005 05:02:15 -0000 1.16 @@ -1036,7 +1036,7 @@ evd = ewl_entry_text_get(e); ewl_callback_call_with_event_data(w, EWL_CALLBACK_VALUE_CHANGED, evd); - FREE(evd); + IF_FREE(evd); } else { ewl_entry_text_insert(e, "\n", ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor))); @@ -1169,20 +1169,22 @@ if (ev->clicks == 2) { char *s; - int start, end; + int start = 0, end = 0; start = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor)); s = ewl_entry_text_get(e); - while ((s[start] != ' ') && (s[start] != '\t') - && (s[start] != '\n') && (--start > 0)); + if (s) + while ((s[start] != ' ') && (s[start] != '\t') + && (s[start] != '\n') && (--start > 0)); if (start < 0) start++; end = start; - while ((s[end + 1] != ' ') && (s[end + 1] != '\t') - && (s[end + 1] != '\n') && (++end < len)); + if (s) + while ((s[end + 1] != ' ') && (s[end + 1] != '\t') + && (s[end + 1] != '\n') && (++end < len)); ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), end); @@ -1258,6 +1260,8 @@ pos = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor)); str = ewl_entry_text_get(e); + if (!str) + DRETURN(DLEVEL_STABLE); len = strlen(str); FREE(str); @@ -1286,23 +1290,27 @@ if (e->multiline) { len = ewl_entry_length_get(e); - nline = start = bp = - ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor)); + bp = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor)); + nline = start = bp; s = ewl_entry_text_get(e); - while (--start > 1 && s[start] != '\n'); + if (s) { + while (--start > 1 && s[start] != '\n'); - if( s[start] == '\n' ) - start++; + if( s[start] == '\n' ) + start++; + } lpos = bp - start - 1; - while (nline < len && s[nline++] != '\n'); + if (s) + while (nline < len && s[nline++] != '\n'); nend = nline; - while (nend < len && s[nend++] != '\n'); + if (s) + while (nend < len && s[nend++] != '\n'); nlen = nend - nline; ------------------------------------------------------- This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes! http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs