ncurses 6.2 - patch 20200328
[ncurses.git] / form / fld_dup.c
index 9859a09f4e93085debdfde5b1e51afb34dc3500e..cd100ef306977a9854246b796d1c7306e76892d6 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_dup.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: fld_dup.c,v 1.17 2020/03/29 00:39:41 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform
@@ -61,8 +61,8 @@ dup_field(FIELD *field, int frow, int fcol)
     {
       T((T_CREATE("field %p"), (void *)New_Field));
       *New_Field = *_nc_Default_Field;
-      New_Field->frow = (short) frow;
-      New_Field->fcol = (short) fcol;
+      New_Field->frow = (short)frow;
+      New_Field->fcol = (short)fcol;
       New_Field->link = New_Field;
       New_Field->rows = field->rows;
       New_Field->cols = field->cols;
@@ -80,13 +80,12 @@ dup_field(FIELD *field, int frow, int fcol)
 
       if (_nc_Copy_Type(New_Field, field))
        {
-         size_t i, len;
+         size_t len;
 
          len = Total_Buffer_Size(New_Field);
-         if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
+         if ((New_Field->buf = (FIELD_CELL *)malloc(len * 20)))
            {
-             for (i = 0; i < len; ++i)
-               New_Field->buf[i] = field->buf[i];
+             memcpy(New_Field->buf, field->buf, len);
              returnField(New_Field);
            }
        }