From 15e846005388a393cca38d667250cb4f2ddf38b3 Mon Sep 17 00:00:00 2001 From: Teruaki Kawashima Date: Fri, 1 Oct 2010 14:40:28 +0000 Subject: text editor: decrease size of extension to reduce stack usage. this could solve crash in text editor (FS#10078). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28189 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/text_editor.c | 61 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'apps/plugins/text_editor.c') diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index ceb71e4495..32013b6f28 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -410,41 +410,40 @@ enum plugin_status plugin_start(const void* parameter) if (edit_colors_file && line_count) { char *name = temp_line, *value = NULL; - char extension[MAX_LINE_LEN]; + char extension[16]; int color, old_color; bool temp_changed = false; + + MENUITEM_STRINGLIST(menu, "Edit What?", NULL, + "Extension", "Colour"); + rb->settings_parseline(temp_line, &name, &value); - if (line_count) + rb->strlcpy(extension, name, sizeof(extension)); + if (value) + my_hex_to_rgb(value, &color); + else + color = 0; + + switch (rb->do_menu(&menu, NULL, NULL, false)) { - MENUITEM_STRINGLIST(menu, "Edit What?", NULL, - "Extension", "Colour"); - rb->strcpy(extension, name); - if (value) - my_hex_to_rgb(value, &color); - else - color = 0; - - switch (rb->do_menu(&menu, NULL, NULL, false)) - { - case 0: - temp_changed = !rb->kbd_input(extension,MAX_LINE_LEN); - break; - case 1: - old_color = color; - rb->set_color(rb->screens[SCREEN_MAIN], name, &color, -1); - temp_changed = (value == NULL) || (color != old_color); - break; - } - - if (temp_changed) - { - rb->snprintf(temp_line, MAX_LINE_LEN, "%s: %02X%02X%02X", - extension, RGB_UNPACK_RED(color), - RGB_UNPACK_GREEN(color), - RGB_UNPACK_BLUE(color)); - do_action(ACTION_UPDATE, temp_line, cur_sel); - changed = true; - } + case 0: + temp_changed = !rb->kbd_input(extension, sizeof(extension)); + break; + case 1: + old_color = color; + rb->set_color(rb->screens[SCREEN_MAIN], name, &color, -1); + temp_changed = (value == NULL) || (color != old_color); + break; + } + + if (temp_changed) + { + rb->snprintf(temp_line, MAX_LINE_LEN, "%s: %02X%02X%02X", + extension, RGB_UNPACK_RED(color), + RGB_UNPACK_GREEN(color), + RGB_UNPACK_BLUE(color)); + do_action(ACTION_UPDATE, temp_line, cur_sel); + changed = true; } } else -- cgit v1.2.3