diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-10-01 14:40:28 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-10-01 14:40:28 +0000 |
commit | 15e846005388a393cca38d667250cb4f2ddf38b3 (patch) | |
tree | f6cccbbe068d095527bd0e91d0ca1be52dc7a28d | |
parent | 55a63609ef1bf24c3594eeb2f6eca92cba81bae5 (diff) |
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
-rw-r--r-- | apps/plugins/text_editor.c | 61 |
1 files changed, 30 insertions, 31 deletions
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 |