From b24c34920499ddc761f55e5cad1f1a7bdcee8a6b Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 1 Oct 2015 05:08:05 +0200 Subject: [PATCH] Some code improvements --- src/fmenuitem.cpp | 9 ++++++--- src/foptimove.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index f78dbd5f..6a86f60a 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -96,9 +96,12 @@ void FMenuItem::init (FWidget* parent) if ( parent ) { - FMenuList* super_menu_list = dynamic_cast(parent); - setSuperMenu(super_menu_list); - super_menu_list->insert(this); + FMenuList* sm_list = dynamic_cast(parent); + if ( sm_list ) + { + setSuperMenu(sm_list); + sm_list->insert(this); + } if ( isMenuBar(parent) ) // Parent is menubar { diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 0f3af13f..fa792d88 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -412,7 +412,9 @@ int FOptiMove::relative_move ( char*& move if ( F_column_address.cap ) { - strcat (hmove, tparm(F_column_address.cap, to_x)); + strncat ( hmove + , tparm(F_column_address.cap, to_x) + , sizeof(hmove) - strlen(hmove) - 1 ); htime = F_column_address.duration; } @@ -637,13 +639,13 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew) break; case 2: - strcpy (move_ptr, F_carriage_return.cap); + strncpy (move_ptr, F_carriage_return.cap, sizeof(move_buf) - 1); move_ptr += F_carriage_return.length; relative_move (move_ptr, 0, yold, xnew, ynew); break; case 3: - strcpy (move_ptr, F_cursor_home.cap); + strncpy (move_ptr, F_cursor_home.cap, sizeof(move_buf) - 1); move_ptr += F_cursor_home.length; relative_move (move_ptr, 0, 0, xnew, ynew); break;