termio: fixed null pointer dereferencing issue.

This fixes coverity CID 1100645.
This commit is contained in:
Daniel Juyung Seo 2013-11-08 08:32:47 +09:00
parent f5df6ce99d
commit 20afe23c5b
1 changed files with 7 additions and 4 deletions

View File

@ -1824,10 +1824,13 @@ _take_selection(Evas_Object *obj, Elm_Sel_Type type)
char *tmp = termio_selection_get(obj, start_x, i, end_x, i,
&len);
eina_strbuf_append_length(sb, tmp, len);
if (len && tmp[len - 1] != '\n')
eina_strbuf_append_char(sb, '\n');
free(tmp);
if (tmp)
{
eina_strbuf_append_length(sb, tmp, len);
if (len && tmp[len - 1] != '\n')
eina_strbuf_append_char(sb, '\n');
free(tmp);
}
}
len = eina_strbuf_length_get(sb);
s = eina_strbuf_string_steal(sb);