Print this page
10118 libeti() NULL check after deref


  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*      Copyright (c) 1988 AT&T     */
  23 /*        All Rights Reserved   */
  24 
  25 
  26 /*
  27  *      Copyright (c) 1997, by Sun Microsystems, Inc.
  28  *      All rights reserved.
  29  */
  30 
  31 #pragma ident   "%Z%%M% %I%     %E% SMI"


  32 
  33 /*LINTLIBRARY*/
  34 
  35 #include <sys/types.h>
  36 #include <stdlib.h>
  37 #include "utility.h"
  38 
  39         /*
  40          *  default field
  41          */
  42 
  43 static FIELD default_field =
  44 {
  45                         0,                      /* status       */
  46                         0,                      /* rows         */
  47                         0,                      /* cols         */
  48                         0,                      /* frow         */
  49                         0,                      /* fcol         */
  50                         0,                      /* drows        */
  51                         0,                      /* dcols        */


 320 {
 321         if (!f)
 322                 return (E_BAD_ARGUMENT);
 323 
 324         *rows = f->rows;
 325         *cols = f->cols;
 326         *frow = f->frow;
 327         *fcol = f->fcol;
 328         *nrow = f->nrow;
 329         *nbuf = f->nbuf;
 330         return (E_OK);
 331 }
 332 
 333         /*
 334          *  set_max_field
 335          */
 336 
 337 int
 338 set_max_field(FIELD *f, int max)
 339 {
 340         BOOLEAN onerow = OneRow(f);
 341 
 342         if (!f || max && ((onerow && f->dcols > max) ||





 343             (!onerow && f->drows > max)))
 344                 return (E_BAD_ARGUMENT);
 345 
 346         f->maxgrow = max;
 347         Clr(f, GROWABLE);
 348 
 349         if (!Opt(f, O_STATIC) && ((!max || onerow && f->dcols < max) ||
 350             (!onerow && f->drows < max))) {
 351                 Set(f, GROWABLE);
 352         }
 353 
 354         return (E_OK);
 355 }
 356 
 357         /*
 358          *  dynamic_field_info
 359          */
 360 
 361 int
 362 dynamic_field_info(FIELD *f, int *drows, int *dcols, int *max)




  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*      Copyright (c) 1988 AT&T     */
  23 /*        All Rights Reserved   */
  24 
  25 
  26 /*
  27  *      Copyright (c) 1997, by Sun Microsystems, Inc.
  28  *      All rights reserved.
  29  */
  30 
  31 /*
  32  * Copyright (c) 2018, Joyent, Inc.
  33  */
  34 
  35 /*LINTLIBRARY*/
  36 
  37 #include <sys/types.h>
  38 #include <stdlib.h>
  39 #include "utility.h"
  40 
  41         /*
  42          *  default field
  43          */
  44 
  45 static FIELD default_field =
  46 {
  47                         0,                      /* status       */
  48                         0,                      /* rows         */
  49                         0,                      /* cols         */
  50                         0,                      /* frow         */
  51                         0,                      /* fcol         */
  52                         0,                      /* drows        */
  53                         0,                      /* dcols        */


 322 {
 323         if (!f)
 324                 return (E_BAD_ARGUMENT);
 325 
 326         *rows = f->rows;
 327         *cols = f->cols;
 328         *frow = f->frow;
 329         *fcol = f->fcol;
 330         *nrow = f->nrow;
 331         *nbuf = f->nbuf;
 332         return (E_OK);
 333 }
 334 
 335         /*
 336          *  set_max_field
 337          */
 338 
 339 int
 340 set_max_field(FIELD *f, int max)
 341 {
 342         BOOLEAN onerow;
 343 
 344         if (!f)
 345                 return (E_BAD_ARGUMENT);
 346 
 347         onerow = OneRow(f);
 348 
 349         if (max && ((onerow && f->dcols > max) ||
 350             (!onerow && f->drows > max)))
 351                 return (E_BAD_ARGUMENT);
 352 
 353         f->maxgrow = max;
 354         Clr(f, GROWABLE);
 355 
 356         if (!Opt(f, O_STATIC) && ((!max || onerow && f->dcols < max) ||
 357             (!onerow && f->drows < max))) {
 358                 Set(f, GROWABLE);
 359         }
 360 
 361         return (E_OK);
 362 }
 363 
 364         /*
 365          *  dynamic_field_info
 366          */
 367 
 368 int
 369 dynamic_field_info(FIELD *f, int *drows, int *dcols, int *max)