diff --git a/include/codeb.c b/include/codeb.c index 85eb2145d..8c42eb56f 100755 --- a/include/codeb.c +++ b/include/codeb.c @@ -1049,6 +1049,7 @@ char* DB_index_getkey(int handle) static char key[MAXLEN]; TAG4 *t; int klen; + const char* src; HANDLE2DATASTR(handle, data); @@ -1056,8 +1057,14 @@ char* DB_index_getkey(int handle) return(NULL); klen=a4tagKeyLen(data); if (klen > (MAXLEN-1)) klen=MAXLEN-1; - memcpy(key,a4tagKey(data),klen); /* tfile4key non restituisce una null terminated string */ - key[klen]='\0'; + src = a4tagKey(data); + if (src != NULL) + { + memcpy(key,src,klen); /* tfile4key non restituisce una null terminated string */ + key[klen]='\0'; + } + else + key[0] = '\0'; return key; } diff --git a/include/msksheet.cpp b/include/msksheet.cpp index 1f0028f8f..741ecc49e 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -3038,12 +3038,18 @@ bool TSheet_field::on_hit() TSpreadsheet* s = (TSpreadsheet*)_ctl; if (s->auto_append() && items() == 0 && !m.query_mode()) - s->add_row_auto(); // Inserisco automaticamente la prima riga vuota nello sheet - force_update(); - if (items() > 0) { - m.notify_focus_field(dlg()); // Fa' credere alla maschera che ha il focus ... - select(0, -2, TRUE); // ... cosi' la set_focus_cell funziona bene + s->add_row_auto(); // Inserisco automaticamente la prima riga vuota nello sheet + force_update(); + } + else + { + force_update(); + if (items() > 0) + { + m.notify_focus_field(dlg()); // Fa' credere alla maschera che ha il focus ... + select(0, -2, TRUE); // ... cosi' la set_focus_cell funziona bene + } } set_dirty(FALSE);