dataman: allow writing empty items with nullptr pointer to data

This commit is contained in:
Anton Babushkin 2014-06-09 16:09:03 +02:00
parent a6cf04a6ff
commit 4ad435b483
2 changed files with 4 additions and 2 deletions

View File

@ -324,7 +324,9 @@ _write(dm_item_t item, unsigned char index, dm_persitence_t persistence, const v
buffer[1] = persistence;
buffer[2] = 0;
buffer[3] = 0;
memcpy(buffer + DM_SECTOR_HDR_SIZE, buf, count);
if (count > 0) {
memcpy(buffer + DM_SECTOR_HDR_SIZE, buf, count);
}
count += DM_SECTOR_HDR_SIZE;
len = -1;

View File

@ -133,7 +133,7 @@ extern "C" {
in this header, but till I find it a better home here it is */
typedef struct {
char current_offboard_waypoint_id; /* the index of the active offboard waypoint data */
char offboard_waypoint_id; /* the index of the active offboard waypoint data */
/* (DM_KEY_WAYPOINTS_OFFBOARD_n) or -1 for none */
} persistent_system_state_t;