nus-yam/ex-repair huggingface dataset:
Buggy code:
 opj_pi_iterator_t * opj_pi_create_decode ( opj_image_t * p_image, opj_cp_t * p_cp, OPJ_UINT32 p_tile_no ) { OPJ_UINT32 pino ; OPJ_UINT32 compno, resno ; OPJ_UINT32 * l_tmp_data ; OPJ_UINT32 * * l_tmp_ptr ; OPJ_UINT32 l_max_res ; OPJ_UINT32 l_max_prec ; OPJ_INT32 l_tx0, l_tx1, l_ty0, l_ty1 ; OPJ_UINT32 l_dx_min, l_dy_min ; OPJ_UINT32 l_bound ; OPJ_UINT32 l_step_p, l_step_c, l_step_r, l_step_l ; OPJ_UINT32 l_data_stride ; opj_pi_iterator_t * l_pi = 00 ; opj_tcp_t * l_tcp = 00 ; const opj_tccp_t * l_tccp = 00 ; opj_pi_comp_t * l_current_comp = 00 ; opj_image_comp_t * l_img_comp = 00 ; opj_pi_iterator_t * l_current_pi = 00 ; OPJ_UINT32 * l_encoding_value_ptr = 00 ; assert ( p_cp!= 00 ) ; assert ( p_image!= 00 ) ; assert ( p_tile_no < p_cp -> tw * p_cp -> th ) ; l_tcp = & p_cp -> tcps [ p_tile_no ] ; l_bound = l_tcp -> numpocs + 1 ; l_data_stride = 4 * OPJ_J2K_MAXRLVLS ; l_tmp_data = ( OPJ_UINT32 * ) opj_malloc ( l_data_stride * p_image -> numcomps * sizeof ( OPJ_UINT32 ) ) ; if (! l_tmp_data ) { return 00 ; } l_tmp_ptr = ( OPJ_UINT32 * * ) opj_m

Fix:
<S2SV_ModStart> -> include = 00 ; if ( l_step_l <= ( SIZE_MAX // ( l_tcp -> numlayers + 1U ) ) ) { l_current_pi -> include = <S2SV_ModStart> ) ) ; }
Buggy code:
 int vpx_img_read ( vpx_image_t * img, FILE * file ) { int plane ; for ( plane = 0 ; plane < 3 ; ++ plane ) { unsigned char * buf = img -> planes [ plane ] ; const int stride = img -> stride [ plane ] ; <START_BUG> const int w = vpx_img_plane_width ( img, plane ) ; <END_BUG> const int h = vpx_img_plane_height ( img, plane ) ; int y ; for ( y = 0 ; y < h ; ++ y ) {  if ( fread ( buf, 1, w, file )!= w ) <START_BUG> return 0 ; buf += stride ; } } return 1 ; }<END_BUG>

Fix:
<S2SV_ModStart>, plane ) * ( ( img -> fmt & VPX_IMG_FMT_HIGHBITDEPTH )? 2 : 1 ) <S2SV_ModStart> file )!= ( size_t )
Buggy code:
 int bson_check_field_name ( bson * b, const char * string, <START_BUG> const int length ) { <END_BUG> return bson_validate_string ( b, ( const unsigned char * ) string, length, 1, 1, 1 ) ; }

Fix:
<S2SV_ModStart> string, const size_t <S2SV_ModEnd> length ) {
Buggy code:
 <START_BUG> static void addModuleArgument ( sqlite3 * db, Table * pTable, char * zArg ) { <END_BUG>  int nBytes = sizeof ( char * ) * ( 2 + pTable -> nModuleArg ) ; <START_BUG> <END_BUG> char * * azModuleArg ;  azModuleArg = sqlite3DbRealloc ( db, pTable -> azModuleArg, nBytes ) ; if ( azModuleArg == 0 ) { sqlite3DbFree ( db, zArg ) ; } else { int i = pTable -> nModuleArg ++ ; azModuleArg [ i ] = zArg ; azModuleArg [ i + 1 ] = 0 ; pTable -> azModuleArg = azModuleArg ; } }

Fix:
<S2SV_ModStart> void addModuleArgument ( Parse * pParse <S2SV_ModEnd>, Table * <S2SV_ModStart> zArg ) { sqlite3_int64 <S2SV_ModEnd> nBytes = sizeof <S2SV_ModStart> * azModuleArg ; sqlite3 * db = pParse -> db ; if ( pTable -> nModuleArg + 3 >= db -> aLimit [ SQLITE_LIMIT_COLUMN ] ) { sqlite3ErrorMsg ( pParse, "too <S2SV_blank> many <S2SV_blank> columns <S2SV_blank> on <S2SV_blank> %s", pTable -> zName ) ; }
Buggy code:
 static bool parseOperands ( char * str, ArmOp * op ) { char * t = strdup ( str ) ; int operand = 0 ; char * token = t ; char * x ; int imm_count = 0 ; int mem_opt = 0 ; if (! token ) { return false ; } while ( token ) { char * next = strchr ( token, ',' ) ; if ( next ) { * next ++ = 0 ; } while ( token [ 0 ] ==' ') { <START_BUG> token ++ ; <END_BUG> } op -> operands [ operand ]. type = ARM_NOTYPE ; op -> operands [ operand ]. reg_type = ARM_UNDEFINED ; op -> operands [ operand ]. shift = ARM_NO_SHIFT ; while ( token [ 0 ] ==' '|| token [ 0 ] == '[' || token [ 0 ] == ']' ) { token ++ ; } if (! strncmp ( token, "lsl", 3 ) ) { op -> operands [ operand ]. shift = ARM_LSL ; } else if (! strncmp ( token, "lsr", 3 ) ) { op -> operands [ operand ]. shift = ARM_LSR ; } else if (! strncmp ( token, "asr", 3 ) ) { op -> operands [ operand ]. shift = ARM_ASR ; } if ( op -> operands [ operand ]. shift!= ARM_NO_SHIFT ) { op -> operands_count ++ ; op -> operands [ operand ]. shift_amount = r_num_math ( NULL, token + 4 ) ; if ( op -> operands [ operand ]. shift_amount > 63 ) { return false ; } operand ++ ; token = next ; continue ; } switch ( token [ 0 ] ) { case 'x' : x = strchr ( token, ',' ) ; if ( x ) { x [ 0 ] = '\\0' ; } op -> operands_count ++ ; op -> operands [ operand ]. type = ARM_GPR ; op -> operands [ operand ]. reg_type = ARM_REG64 ; op -> operands [ operand ]. reg = r_num_math ( NULL, token + 1 ) ; if ( op -> operands [ operand ]. reg > 31 ) { return false ; } break ; case 'w' : op -> operands_count

Fix:
<S2SV_ModStart> { token ++ ; } if ( operand >= MAX_OPERANDS ) { eprintf ( "Too <S2SV_blank> many <S2SV_blank> operands\\n" ) ; return false
Buggy code:
 error_t tja1101Init ( NetInterface * interface ) { uint16_t value ; TRACE_INFO ( "Initializing   TJA1101...\\r\\n" ) ; if ( interface -> phyAddr >= 32 ) { interface -> phyAddr = TJA1101_PHY_ADDR ; } if ( interface -> smiDriver!= NULL ) { interface -> smiDriver -> init ( ) ; } if ( interface -> extIntDriver!= NULL ) { interface -> extIntDriver -> init ( ) ; } tja1101WritePhyReg ( interface, TJA1101_BASIC_CTRL, TJA1101_BASIC_CTRL_RESET ) ; while ( tja1101ReadPhyReg ( interface, TJA1101_BASIC_CTRL ) & TJA1101_BASIC_CTRL_RESET ) { } tja1101DumpPhyReg ( interface ) ; value = tja1101ReadPhyReg ( interface, TJA1101_EXTENDED_CTRL ) ; value |= TJA1101_EXTENDED_CTRL_CONFIG_EN ; tja1101WritePhyReg ( interface, TJA1101_EXTENDED_CTRL, value ) ; value = tja1101ReadPhyReg ( interface, TJA1101_CONFIG1 ) ; value &= ~ TJA1101_CONFIG1_MII_MODE ; <START_BUG> value |= TJA1101_CONFIG1_MII_MODE_RMII_25MHZ ; <END_BUG> tja1101WritePhyReg ( interface, TJA1101_CONFIG1, value ) ; value = tja1101ReadPhyReg ( interface, TJA1101_COMM_CTRL ) ; value |= TJA1101_COMM_CTRL_AUTO_OP ; tja1101WritePhyReg ( interface, TJA1101_COMM_CTRL, value ) ; interface -> phyEvent = TRUE ; osSetEvent ( & netEvent ) ; return NO_ERROR ; }

Fix:
<S2SV_ModStart> ; value |= TJA1101_CONFIG1_MII_MODE_RMII_50MHZ_REF_CLK_OUT <S2SV_ModEnd> ; tja1101WritePhyReg (
Buggy code:
 static int ovl_rename2 ( struct inode * olddir, struct dentry * old, struct inode * newdir, struct dentry * new, unsigned int flags ) { int err ; enum ovl_path_type old_type ; enum ovl_path_type new_type ; struct dentry * old_upperdir ; struct dentry * new_upperdir ; struct dentry * olddentry ; struct dentry * newdentry ; struct dentry * trap ; bool old_opaque ; bool new_opaque ; bool new_create = false ; bool cleanup_whiteout = false ; bool overwrite =! ( flags & RENAME_EXCHANGE ) ; bool is_dir = d_is_dir ( old ) ; bool new_is_dir = false ; struct dentry * opaquedir = NULL ; const struct cred * old_cred = NULL ; struct cred * override_cred = NULL ; err = - EINVAL ; if ( flags & ~ ( RENAME_EXCHANGE | RENAME_NOREPLACE ) ) goto out ; flags &= ~ RENAME_NOREPLACE ; err = ovl_check_sticky ( old ) ; if ( err ) goto out ; old_type = ovl_path_type ( old ) ; err = - EXDEV ; if ( OVL_TYPE_MERGE_OR_LOWER ( old_type ) && is_dir ) goto out ; if ( new -> d_inode ) { err = ovl_check_sticky ( new ) ; if ( err ) goto out ; if ( d_is_dir ( new ) ) new_is_dir = true ; new_type = ovl_path_type ( new ) ; err = - EXDEV ; if (! overwrite && OVL_TYPE_MERGE_OR_LOWER ( new_type ) && new_is_dir ) goto out ; err = 0 ; if (! OVL_TYPE_UPPER ( new_type ) &&! OVL_TYPE_UPPER ( old_type ) ) { if ( ovl_dentry_lower ( old ) -> d_inode == ovl_dentry_lower ( new ) -> d_inode ) goto out ; } if ( OVL_TYPE_UPPER ( new_type ) && OVL_TYPE_UPPER ( old_type ) ) { if

Fix:
<S2SV_ModStart> ; olddentry = lookup_one_len ( old <S2SV_ModEnd> -> d_name. <S2SV_ModStart>. name, old_upperdir, old <S2SV_ModEnd> -> d_name. <S2SV_ModStart> = PTR_ERR ( olddentry <S2SV_ModEnd> ) ; if <S2SV_ModStart> ( IS_ERR ( olddentry <S2SV_ModEnd> ) ) goto <S2SV_ModStart> goto out_unlock ; <S2SV_ModEnd> err = - <S2SV_ModStart> if ( olddentry!= ovl_dentry_upper ( old ) ) goto out_dput_old ; newdentry = lookup_one_len ( new -> d_name. name, new_upperdir, new -> d_name. len ) ; err = PTR_ERR ( newdentry ) ; if ( IS_ERR ( newdentry ) ) goto out_dput_old ; err = - ESTALE ; if ( ovl_dentry_upper ( new ) ) { if ( opaquedir ) { if ( newdentry!= opaquedir <S2SV_ModEnd> ) goto out_dput <S2SV_ModStart> goto out_dput ; } else { if ( newdentry!= ovl_dentry_upper ( new ) <S2SV_ModEnd> ) goto out_dput <S2SV_ModStart> goto out_dput ; } } else
Buggy code:
 void recovery_delete_character ( void ) <START_BUG> { <END_BUG> if ( strlen ( mnemonic ) > 0 ) { mnemonic [ strlen ( mnemonic ) - 1 ] = '\\0' ; } next_character ( ) ; }

Fix:
<S2SV_ModStart> void ) { if (! recovery_started ) { recovery_abort ( ) ; fsm_sendFailure ( FailureType_Failure_UnexpectedMessage, "Not <S2SV_blank> in <S2SV_blank> Recovery <S2SV_blank> mode" ) ; layoutHome ( ) ; return ; }
Buggy code:
 int snd_timer_close ( struct snd_timer_instance * timeri ) { struct snd_timer * timer = NULL ; struct snd_timer_instance * slave, * tmp ; if ( snd_BUG_ON (! timeri ) ) return - ENXIO ; snd_timer_stop ( timeri ) ; if ( timeri -> flags & SNDRV_TIMER_IFLG_SLAVE ) { spin_lock_irq ( & slave_active_lock ) ; while ( timeri -> flags & SNDRV_TIMER_IFLG_CALLBACK ) { spin_unlock_irq ( & slave_active_lock ) ; udelay ( 10 ) ; spin_lock_irq ( & slave_active_lock ) ; } spin_unlock_irq ( & slave_active_lock ) ; mutex_lock ( & register_mutex ) ; list_del ( & timeri -> open_list ) ; mutex_unlock ( & register_mutex ) ; } else { timer = timeri -> timer ; if ( snd_BUG_ON (! timer ) ) goto out ; spin_lock_irq ( & timer -> lock ) ; while ( timeri -> flags & SNDRV_TIMER_IFLG_CALLBACK ) { spin_unlock_irq ( & timer -> lock ) ; udelay ( 10 ) ; spin_lock_irq ( & timer -> lock ) ; } spin_unlock_irq ( & timer -> lock ) ; mutex_lock ( & register_mutex ) ; list_del ( & timeri -> open_list ) ; if ( timer && list_empty ( & timer -> open_list_head ) && timer -> hw. close ) timer -> hw. close ( timer ) ; <START_BUG> list_for_each_entry_safe ( slave, tmp, & timeri -> slave_list_head, <END_BUG> open_list ) {  spin_lock_irq ( & slave_active_lock ) ; <START_BUG> _snd_timer_stop ( slave, 1, SNDRV_TIMER_EVENT_RESOLUTION ) ; list_move_tail ( & slave -> open_list, & snd_timer_slave_list ) ; slave -> master = NULL ; slave -> timer = NULL ; <END_BUG> spin_unlock_irq ( & slave_active_lock ) ;  <START_BUG> } <END_BUG> mutex

Fix:
<S2SV_ModStart> timer ) ; spin_lock_irq ( & slave_active_lock ) ; spin_lock ( & timer -> lock ) ; <S2SV_ModStart> open_list ) { <S2SV_ModEnd> list_move_tail ( & <S2SV_ModStart> = NULL ; list_del_init ( & slave -> ack_list ) ; list_del_init ( & slave -> active_list ) ; } spin_unlock ( & timer -> lock ) ; <S2SV_ModStart> slave_active_lock ) ; <S2SV_ModEnd> mutex_unlock ( &
Buggy code:
 static int DecodeGifImg ( struct ngiflib_img * i ) { struct ngiflib_decode_context context ; long npix ; u8 * stackp ; u8 * stack_top ; u16 clr ; u16 eof ; u16 free ; u16 act_code = 0 ; u16 old_code = 0 ; u16 read_byt ; u16 ab_prfx [ 4096 ] ; u8 ab_suffx [ 4096 ] ; u8 ab_stack [ 4096 ] ; u8 flags ; u8 casspecial = 0 ; if (! i ) return - 1 ; i -> posX = GetWord ( i -> parent ) ; i -> posY = GetWord ( i -> parent ) ; i -> width = GetWord ( i -> parent ) ; i -> height = GetWord ( i -> parent ) ; if ( ( i -> width > i -> parent -> width ) || ( i -> height > i -> parent -> height ) ) { # if! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log, "***   ERROR   ***   Image   bigger   than   global   GIF   canvas  !\\n" ) ; # endif return - 1 ; } if ( ( i -> posX + i -> width ) > i -> parent -> width ) { # if! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log, "***   WARNING   ***   Adjusting   X   position\\n" ) ; # endif i -> posX = i -> parent -> width - i -> width ; } if ( ( i -> posY + i -> height ) > i -> parent -> height ) { # if! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log, "***   WARNING   ***   Adjusting   Y   position\\n" ) ; # endif i -> posY = i -> parent -> height - i -> height ; } context. Xtogo = i -> width ; context. curY = i -> posY ; # ifdef NGIFLIB_INDEXED_ONLY # ifdef NGIFLIB_ENABLE_CALLBACKS context. line_p. p8 = i -> parent

Fix:
<S2SV_ModStart> = act_code ; if ( npix > 0 ) <S2SV_ModStart> = casspecial ; if ( npix >= ( <S2SV_ModEnd> stack_top - stackp <S2SV_ModStart> - stackp ) ) { WritePixels ( i, & context, stackp, stack_top - stackp ) ; } else if ( npix > 0 ) { WritePixels ( i, & context, stackp, npix ) ; } <S2SV_ModEnd> npix -= (
Buggy code:
 <START_BUG> static void encode_superblock ( VP9_COMP * cpi, TOKENEXTRA * * t, int output_enabled, <END_BUG>  int mi_row, int mi_col, BLOCK_SIZE bsize ) { <START_BUG> VP9_COMMON * const cm = & cpi -> common ; <END_BUG> MACROBLOCK * const x = & cpi -> mb ;  MACROBLOCKD * const xd = & x -> e_mbd ; MODE_INFO * * mi_8x8 = xd -> mi ; MODE_INFO * mi = mi_8x8 [ 0 ] ; MB_MODE_INFO * mbmi = & mi -> mbmi ; <START_BUG> PICK_MODE_CONTEXT * ctx = get_block_context ( x, bsize ) ; <END_BUG> unsigned int segment_id = mbmi -> segment_id ; const int mis = cm -> mi_stride ; const int mi_width = num_8x8_blocks_wide_lookup [ bsize ] ; const int mi_height = num_8x8_blocks_high_lookup [ bsize ] ;  x -> skip_recode =! x -> select_txfm_size && mbmi -> sb_type >= BLOCK_8X8 && <START_BUG> cpi -> oxcf. aq_mode!= COMPLEXITY_AQ && cpi -> oxcf. aq_mode!= CYCLIC_REFRESH_AQ && cpi -> sf. allow_skip_recode ; <END_BUG> x -> skip_optimize = ctx -> is_coded ;  ctx -> is_coded = 1 ; x -> use_lp32x32fdct = cpi -> sf. use_lp32x32fdct ; x -> skip_encode = (! output_enabled && cpi -> sf. skip_encode_frame && x -> q_index < QIDX_SKIP_THRESH ) ; if ( x -> skip_encode ) return ; <START_BUG> if ( cm -> frame_type == KEY_FRAME ) { <END_BUG> if ( cpi -> oxcf. tuning == VP8_TUNE_SSIM ) { adjust_act_zbin ( cpi, x ) ; vp9_update_zbin_extra ( cpi, x ) ; } } else {  set_ref_ptrs ( cm, xd, mbmi -> ref_frame [ 0 ], mbmi ->

Fix:
<S2SV_ModStart> * cpi, ThreadData * td, <S2SV_ModStart>, BLOCK_SIZE bsize, PICK_MODE_CONTEXT * ctx <S2SV_ModStart> x = & td <S2SV_ModEnd> -> mb ; <S2SV_ModStart> -> mbmi ; const int seg_skip = segfeature_active ( & cm -> seg, mbmi -> segment_id, SEG_LVL_SKIP ) <S2SV_ModEnd> ; const int <S2SV_ModStart>! x -> select_tx_size <S2SV_ModEnd> && mbmi -> <S2SV_ModStart>. allow_skip_recode ; if (! x -> skip_recode &&! cpi -> sf. use_nonrd_pick_mode ) memset ( x -> skip_txfm, 0, sizeof ( x -> skip_txfm ) ) ; <S2SV_ModStart> ; if (! is_inter_block ( mbmi ) ) { int plane ; mbmi -> skip = 1 ; for ( plane = 0 ; plane < MAX_MB_PLANE ; ++ plane ) vp9_encode_intra_block_plane ( x, MAX ( bsize, BLOCK_8X8 ), plane ) ; if ( output_enabled ) sum_intra_stats ( td -> counts, mi ) ; vp9_tokenize_sb ( cpi, td,
Buggy code:
 static void exif_mnote_data_canon_load ( ExifMnoteData * ne, const unsigned char * buf, unsigned int buf_size ) { ExifMnoteDataCanon * n = ( ExifMnoteDataCanon * ) ne ; ExifShort c ; <START_BUG> size_t i, tcount, o, datao ; <END_BUG> if (! n ||! buf ||! buf_size ) { exif_log ( ne -> log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifMnoteCanon", "Short   MakerNote" ) ; return ; } datao = 6 + n -> offset ; if ( CHECKOVERFLOW ( datao, buf_size, 2 ) ) { exif_log ( ne -> log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifMnoteCanon", "Short   MakerNote" ) ; return ; } c = exif_get_short ( buf + datao, n -> order ) ; datao += 2 ; exif_mnote_data_canon_clear ( n ) ; n -> entries = exif_mem_alloc ( ne -> mem, sizeof ( MnoteCanonEntry ) * c ) ; if (! n -> entries ) { EXIF_LOG_NO_MEMORY ( ne -> log, "ExifMnoteCanon", sizeof ( MnoteCanonEntry ) * c ) ; return ; } tcount = 0 ; for ( i = c, o = datao ; i ; -- i, o += 12 ) { size_t s ; memset ( & n -> entries [ tcount ], 0, sizeof ( MnoteCanonEntry ) ) ; if ( CHECKOVERFLOW ( o, buf_size, 12 ) ) { exif_log ( ne -> log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifMnoteCanon", "Short   MakerNote" ) ; break ; } n -> entries [ tcount ]. tag = exif_get_short ( buf + o, n -> order ) ; n -> entries [ tcount ]. format = exif_get_short ( buf + o + 2, n -> order ) ; n -> entries [ tcount ]. components = exif_get_long ( buf + o + 4, n -> order ) ; n -> entries [ tcount ]

Fix:
<S2SV_ModStart> o, datao ; long failsafe_size = 0 <S2SV_ModStart> ) ; } failsafe_size += mnote_canon_entry_count_values ( & n -> entries [ tcount ] ) ; if ( failsafe_size > FAILSAFE_SIZE_MAX ) { exif_mem_free ( ne -> mem, n -> entries [ tcount ]. data ) ; exif_log ( ne -> log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifMnoteCanon", "Failsafe <S2SV_blank> tag <S2SV_blank> size <S2SV_blank> overflow <S2SV_blank> (%lu <S2SV_blank> > <S2SV_blank> %ld)", failsafe_size, FAILSAFE_SIZE_MAX ) ; break ; }
Buggy code:
 static int fit_image_verify_sig ( const void * fit, int image_noffset, const char * data, size_t size, const void * sig_blob, int sig_offset ) { int noffset ; char * err_msg = "" ; int verified = 0 ; int ret ; fdt_for_each_subnode ( noffset, fit, image_noffset ) { <START_BUG> const char * name = fit_get_name ( fit, noffset, NULL ) ; <END_BUG> if (! strncmp ( name, FIT_SIG_NODENAME, strlen ( FIT_SIG_NODENAME ) ) ) { ret = fit_image_check_sig ( fit, noffset, data, size, - 1, & err_msg ) ; if ( ret ) { puts ( "-   " ) ; } else { puts ( "+   " ) ; verified = 1 ; break ; } } } if ( noffset == - FDT_ERR_TRUNCATED || noffset == - FDT_ERR_BADSTRUCTURE ) { err_msg = "Corrupted   or   truncated   tree" ; goto error ; } return verified? 0 : - EPERM ; error : printf ( "   error!\\n%s   for   \'%s\'   hash   node   in   \'%s\'   image   node\\n", err_msg, fit_get_name ( fit, noffset, NULL ), fit_get_name ( fit, image_noffset, NULL ) ) ; return - 1 ; }

Fix:
<S2SV_ModStart> NULL ) ; if ( strchr ( name, '@' ) ) { err_msg = "Node <S2SV_blank> name <S2SV_blank> contains <S2SV_blank> @" ; goto error ; }
Buggy code:
 static int toggle_utf8 ( const char * name, int fd, bool utf8 ) { int r ; struct termios tc = { } ; <START_BUG> assert ( name ) ; <END_BUG> r = ioctl ( fd, KDSKBMODE, utf8? K_UNICODE : K_XLATE ) ; if ( r < 0 ) return log_warning_errno ( errno, "Failed   to   %s   UTF-8   kbdmode   on   %s:   %m", enable_disable ( utf8 ), name ) ; r = loop_write ( fd, utf8? "\\033%G" : "\\033%@", 3, false ) ; if ( r < 0 ) return log_warning_errno ( r, "Failed   to   %s   UTF-8   term   processing   on   %s:   %m", enable_disable ( utf8 ), name ) ; r = tcgetattr ( fd, & tc ) ; if ( r >= 0 ) { SET_FLAG ( tc. c_iflag, IUTF8, utf8 ) ; r = tcsetattr ( fd, TCSANOW, & tc ) ; } if ( r < 0 ) return log_warning_errno ( errno, "Failed   to   %s   iutf8   flag   on   %s:   %m", enable_disable ( utf8 ), name ) ; log_debug ( "UTF-8   kbdmode   %sd   on   %s", enable_disable ( utf8 ), name ) ; return 0 ; }

Fix:
<S2SV_ModStart> ; assert ( name ) ; r = vt_verify_kbmode ( fd ) ; if ( r == - EBUSY ) { log_warning_errno ( r, "Virtual <S2SV_blank> console <S2SV_blank> %s <S2SV_blank> is <S2SV_blank> not <S2SV_blank> in <S2SV_blank> K_XLATE <S2SV_blank> or <S2SV_blank> K_UNICODE: <S2SV_blank> %m", name ) ; return 0 ; } else if ( r < 0 ) return log_warning_errno ( r, "Failed <S2SV_blank> to <S2SV_blank> verify <S2SV_blank> kbdmode <S2SV_blank> on <S2SV_blank> %s: <S2SV_blank> %m",
Buggy code:
 static int add_attributes ( PyTypeObject * type, char * * attrs, int num_fields ) { <START_BUG> int i, result ; <END_BUG> _Py_IDENTIFIER ( _attributes ) ; PyObject * s, * l = PyTuple_New ( num_fields ) ; if (! l ) return 0 ; for ( i = 0 ; i < num_fields ; i ++ ) { s = PyUnicode_FromString ( attrs [ i ] ) ; if (! s ) { Py_DECREF ( l ) ; return 0 ; } PyTuple_SET_ITEM ( l, i, s ) ; } result = _PyObject_SetAttrId ( ( PyObject * ) type, & PyId__attributes, l ) >= 0 ; Py_DECREF ( l ) ; return result ; }

Fix:
<S2SV_ModStart> i, result <S2SV_ModEnd> ; PyObject *
Buggy code:
 static unsigned int unix_dgram_poll ( struct file * file, struct socket * sock, poll_table * wait ) { struct sock * sk = sock -> sk, * other ; unsigned int mask, writable ; sock_poll_wait ( file, sk_sleep ( sk ), wait ) ; mask = 0 ; if ( sk -> sk_err ||! skb_queue_empty ( & sk -> sk_error_queue ) ) mask |= POLLERR | ( sock_flag ( sk, SOCK_SELECT_ERR_QUEUE )? POLLPRI : 0 ) ; if ( sk -> sk_shutdown & RCV_SHUTDOWN ) mask |= POLLRDHUP | POLLIN | POLLRDNORM ; if ( sk -> sk_shutdown == SHUTDOWN_MASK ) mask |= POLLHUP ; if (! skb_queue_empty ( & sk -> sk_receive_queue ) ) mask |= POLLIN | POLLRDNORM ; if ( sk -> sk_type == SOCK_SEQPACKET ) { if ( sk -> sk_state == TCP_CLOSE ) mask |= POLLHUP ; if ( sk -> sk_state == TCP_SYN_SENT ) return mask ; } if (! ( poll_requested_events ( wait ) & ( POLLWRBAND | POLLWRNORM | POLLOUT ) ) ) return mask ; writable = unix_writable ( sk ) ; <START_BUG> other = unix_peer_get ( sk ) ; <END_BUG> if ( other ) {  if ( unix_peer ( other )!= sk ) { <START_BUG> sock_poll_wait ( file, & unix_sk ( other ) -> peer_wait, wait ) ; <END_BUG> if ( unix_recvq_full ( other ) )  writable = 0 ; <START_BUG> } <END_BUG> sock_put ( other ) ; } if ( writable ) mask |= POLLOUT | POLLWRNORM | POLLWRBAND ; else set_bit ( SOCK_ASYNC_NOSPACE, & sk -> sk_socket -> flags ) ; return mask ; }

Fix:
<S2SV_ModStart> sk ) ; if ( writable ) { unix_state_lock ( sk ) ; other = unix_peer ( sk ) ; if ( other && unix_peer ( <S2SV_ModEnd> other )!= <S2SV_ModStart> )!= sk && <S2SV_ModEnd> unix_recvq_full ( other <S2SV_ModStart> ( other ) && unix_dgram_peer_wake_me ( sk, other ) <S2SV_ModStart> = 0 ; unix_state_unlock ( sk <S2SV_ModEnd> ) ; }
Buggy code:
 void vp9_setup_in_frame_q_adj ( VP9_COMP * cpi ) { VP9_COMMON * const cm = & cpi -> common ; struct segmentation * const seg = & cm -> seg ; <START_BUG> vp9_clear_system_state ( ) ; <END_BUG> if ( cm -> frame_type == KEY_FRAME || cpi -> refresh_alt_ref_frame || ( cpi -> refresh_golden_frame &&! cpi -> rc. is_src_frame_alt_ref ) ) { int segment ;  vpx_memset ( cpi -> segmentation_map, 0, cm -> mi_rows * cm -> mi_cols ) ; <START_BUG> vpx_memset ( cpi -> complexity_map, 0, cm -> mi_rows * cm -> mi_cols ) ; vp9_enable_segmentation ( seg ) ; vp9_clearall_segfeatures ( seg ) ; seg -> abs_delta = SEGMENT_DELTADATA ; vp9_disable_segfeature ( seg, 0, SEG_LVL_ALT_Q ) ; for ( segment = 1 ; segment < 2 ; segment ++ ) { const int qindex_delta = vp9_compute_qdelta_by_rate ( & cpi -> rc, cm -> frame_type, cm -> base_qindex, <END_BUG> in_frame_q_adj_ratio [ segment ] ) ;  vp9_enable_segfeature ( seg, segment, SEG_LVL_ALT_Q ) ; vp9_set_segdata ( seg, segment, SEG_LVL_ALT_Q, qindex_delta ) ; } } <START_BUG> } <END_BUG>

Fix:
<S2SV_ModStart> -> seg ; vpx_clear_system_state <S2SV_ModEnd> ( ) ; <S2SV_ModStart> int segment ; const int aq_strength = get_aq_c_strength ( cm -> base_qindex, cm -> bit_depth ) ; memset ( cpi -> segmentation_map, DEFAULT_AQ2_SEG, cm -> mi_rows * cm -> mi_cols ) ; vp9_clearall_segfeatures ( seg ) ; if ( cpi -> rc. sb64_target_rate < 256 ) { vp9_disable_segmentation ( seg ) ; return ; } vp9_enable_segmentation ( seg ) ; seg -> abs_delta = SEGMENT_DELTADATA ; vp9_disable_segfeature ( seg, DEFAULT_AQ2_SEG, SEG_LVL_ALT_Q ) ; for ( segment = 0 ; segment < AQ_C_SEGMENTS ; ++ segment ) { int qindex_delta ; if ( segment == DEFAULT_AQ2_SEG ) continue ; <S2SV_ModEnd> qindex_delta = vp9_compute_qdelta_by_rate <S2SV_ModStart> -> base_qindex, aq_c_q_adj
Buggy code:
 static int gemsafe_get_cert_len ( sc_card_t * card ) { int r ; u8 ibuf [ GEMSAFE_MAX_OBJLEN ] ; u8 * iptr ; struct sc_path path ; struct sc_file * file ; size_t objlen, certlen ; unsigned int ind, i = 0 ; sc_format_path ( GEMSAFE_PATH, & path ) ; r = sc_select_file ( card, & path, & file ) ; if ( r!= SC_SUCCESS ||! file ) return SC_ERROR_INTERNAL ; r = sc_read_binary ( card, 0, ibuf, GEMSAFE_READ_QUANTUM, 0 ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; objlen = ( ( ( size_t ) ibuf [ 0 ] ) << 8 ) | ibuf [ 1 ] ; sc_log ( card -> ctx, "Stored   object   is   of   size:   %" SC_FORMAT_LEN_SIZE_T "u", objlen ) ; if ( objlen < 1 || objlen > GEMSAFE_MAX_OBJLEN ) { sc_log ( card -> ctx, "Invalid   object   size:   %" SC_FORMAT_LEN_SIZE_T "u", objlen ) ; return SC_ERROR_INTERNAL ; } ind = 2 ; <START_BUG> while ( ibuf [ ind ] == 0x01 ) { <END_BUG> if ( ibuf [ ind + 1 ] == 0xFE ) { gemsafe_prkeys [ i ]. ref = ibuf [ ind + 4 ] ; sc_log ( card -> ctx, "Key   container   %d   is   allocated   and   uses   key_ref   %d", i + 1, gemsafe_prkeys [ i ]. ref ) ; ind += 9 ; } else { gemsafe_prkeys [ i ]. label = NULL ; gemsafe_cert [ i ]. label = NULL ; sc_log ( card -> ctx, "Key   container   %d   is   unallocated", i + 1 ) ; ind += 8 ; } i ++ ; } for ( ; i < gemsafe_cert_max ; i ++ ) { gemsafe_prkeys [ i ]. label = NULL ; gemsafe_cert [ i ]. label = NULL ; } iptr =

Fix:
<S2SV_ModStart> ] == 0x01 && i < gemsafe_cert_max
Buggy code:
 static void build_tree_distribution ( VP9_COMP * cpi, TX_SIZE tx_size, <START_BUG> vp9_coeff_stats * coef_branch_ct ) { <END_BUG>  vp9_coeff_probs_model * coef_probs = cpi -> frame_coef_probs [ tx_size ] ; <START_BUG> vp9_coeff_count * coef_counts = cpi -> coef_counts [ tx_size ] ; unsigned int ( * eob_branch_ct ) [ REF_TYPES ] [ COEF_BANDS ] [ COEFF_CONTEXTS ] = cpi -> common. counts. eob_branch [ tx_size ] ; int i, j, k, l, m ; for ( i = 0 ; i < PLANE_TYPES ; ++ i ) { for ( j = 0 ; j < REF_TYPES ; ++ j ) { for ( k = 0 ; k < COEF_BANDS ; ++ k ) { for ( l = 0 ; l < BAND_COEFF_CONTEXTS ( k ) ; ++ l ) { vp9_tree_probs_from_distribution ( vp9_coef_tree, coef_branch_ct [ i ] [ j ] [ k ] [ l ], coef_counts [ i ] [ j ] [ k ] [ l ] ) ; coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ 0 ] [ 1 ] = eob_branch_ct [ i ] [ j ] [ k ] [ l ] - coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ 0 ] [ 0 ] ; for ( m = 0 ; m < UNCONSTRAINED_NODES ; ++ m ) coef_probs [ i ] [ j ] [ k ] [ l ] [ m ] = get_binary_prob ( coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ m ] [ 0 ], coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ m ] [ 1 ] ) ; } } } } }<END_BUG>

Fix:
<S2SV_ModStart> vp9_coeff_stats * coef_branch_ct, <S2SV_ModEnd> vp9_coeff_probs_model * coef_probs <S2SV_ModStart> vp9_coeff_probs_model * coef_probs ) { vp9_coeff_count * coef_counts <S2SV_ModStart> = cpi -> td. rd_counts. <S2SV_ModEnd> coef_counts [ tx_size
Buggy code:
 static void sig_server_connect_copy ( SERVER_CONNECT_REC * * dest, IRC_SERVER_CONNECT_REC * src ) { IRC_SERVER_CONNECT_REC * rec ; g_return_if_fail ( dest!= NULL ) ; if (! IS_IRC_SERVER_CONNECT ( src ) ) return ; rec = g_new0 ( IRC_SERVER_CONNECT_REC, 1 ) ; rec -> chat_type = IRC_PROTOCOL ; rec -> max_cmds_at_once = src -> max_cmds_at_once ; rec -> cmd_queue_speed = src -> cmd_queue_speed ; rec -> max_query_chans = src -> max_query_chans ; rec -> max_kicks = src -> max_kicks ; rec -> max_modes = src -> max_modes ; rec -> max_msgs = src -> max_msgs ; rec -> max_whois = src -> max_whois ; rec -> usermode = g_strdup ( src -> usermode ) ; rec -> alternate_nick = g_strdup ( src -> alternate_nick ) ; rec -> sasl_mechanism = src -> sasl_mechanism ; <START_BUG> rec -> sasl_username = src -> sasl_username ; <END_BUG>  rec -> sasl_password = src -> sasl_password ; <START_BUG> * dest = ( SERVER_CONNECT_REC * ) rec ; }<END_BUG>

Fix:
<S2SV_ModStart> -> sasl_username = g_strdup ( <S2SV_ModStart> src -> sasl_username ) <S2SV_ModStart> -> sasl_password = g_strdup ( <S2SV_ModStart> src -> sasl_password )
Buggy code:
 asmlinkage void do_page_fault ( struct pt_regs * regs, unsigned long writeaccess, unsigned long textaccess, unsigned long address ) { struct task_struct * tsk ; struct mm_struct * mm ; struct vm_area_struct * vma ; const struct exception_table_entry * fixup ; pte_t * pte ; int fault ; tsk = current ; mm = tsk -> mm ; local_irq_enable ( ) ; <START_BUG> perf_sw_event ( PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, address ) ; <END_BUG> if ( in_atomic ( ) ||! mm ) goto no_context ; down_read ( & mm -> mmap_sem ) ; vma = find_vma ( mm, address ) ; if (! vma ) { # ifdef DEBUG_FAULT print_task ( tsk ) ; printk ( "%s:%d   fault,   address   is   0x%08x   PC   %016Lx   textaccess   %d   writeaccess   %d\\n", __func__, __LINE__, address, regs -> pc, textaccess, writeaccess ) ; show_regs ( regs ) ; # endif goto bad_area ; } if ( vma -> vm_start <= address ) { goto good_area ; } if (! ( vma -> vm_flags & VM_GROWSDOWN ) ) { # ifdef DEBUG_FAULT print_task ( tsk ) ; printk ( "%s:%d   fault,   address   is   0x%08x   PC   %016Lx   textaccess   %d   writeaccess   %d\\n", __func__, __LINE__, address, regs -> pc, textaccess, writeaccess ) ; show_regs ( regs ) ; print_vma ( vma ) ; # endif goto bad_area ; } if ( expand_stack ( vma, address ) ) { # ifdef DEBUG_FAULT print_task ( tsk ) ; printk ( "%s:%d   fault,   address   is   0x%08x   PC   %016Lx   textaccess   %d   writeaccess   %d\\n", __func__, __LINE__, address, regs -> pc, textaccess, writeaccess ) ; show_re

Fix:
<S2SV_ModStart>, 1, <S2SV_ModEnd> regs, address <S2SV_ModStart>, 1, <S2SV_ModEnd> regs, address <S2SV_ModStart> PERF_COUNT_SW_PAGE_FAULTS_MIN, 1 <S2SV_ModEnd>, regs,
Buggy code:
 void sink ( int argc, char * * argv, const char * src ) { static BUF buffer ; <START_BUG> struct stat stb ; <END_BUG> enum { YES, NO, DISPLAYED } wrerr ; BUF * bp ; off_t i ; size_t j, count ; int amt, exists, first, ofd ; mode_t mode, omode, mask ; off_t size, statbytes ; unsigned long long ull ;  int setimes, targisdir, wrerrno = 0 ; <START_BUG> char ch, * cp, * np, * targ, * why, * vect [ 1 ], buf [ 2048 ], visbuf [ 2048 ] ; char * * patterns = NULL ; size_t n, npatterns = 0 ; struct timeval tv [ 2 ] ; # define atime tv [ 0 ] # define mtime tv [ 1 ] # define SCREWUP ( str ) { why = str ; goto screwup ; } if ( TYPE_OVERFLOW ( time_t, 0 ) || TYPE_OVERFLOW ( off_t, 0 ) ) SCREWUP ( "Unexpected   off_t//time_t   size" ) ; setimes = targisdir = 0 ; mask = umask ( 0 ) ; if (! pflag ) ( void ) umask ( mask ) ; if ( argc!= 1 ) { run_err ( "ambiguous   target" ) ; exit ( 1 ) ; } targ = * argv ; if ( targetshouldbedirectory ) verifydir ( targ ) ; ( void ) atomicio ( vwrite, remout, "", 1 ) ; if ( stat ( targ, & stb ) == 0 && S_ISDIR ( stb. st_mode ) ) targisdir = 1 ; if ( src!= NULL &&! iamrecursive &&! Tflag ) { if ( brace_expand ( src, & patterns, & npatterns )!= 0 ) fatal ( "%s:   could   not   expand   pattern", __func__ ) ; } for ( first = 1 ; ; first = 0 ) { cp = buf ; if ( atomicio ( read, remin, cp, 1 )!= 1 ) goto done ; if ( * cp ++ == '\\n' ) SCREWUP ( "unexpected   <newline>" ) ; do { if ( atomicio ( read, remin, & ch, sizeof ( ch ) )!=<END_BUG>

Fix:
<S2SV_ModStart> struct stat stb <S2SV_ModEnd> ; BUF * <S2SV_ModStart>, targisdir, wrerr <S2SV_ModEnd> ; char ch <S2SV_ModStart> ; wrerr = 0 <S2SV_ModEnd> ; statbytes = <S2SV_ModStart> { if (! wrerr <S2SV_ModEnd> ) { if <S2SV_ModStart> count ) { note_err ( "%s: <S2SV_blank> %s", np, strerror ( errno ) ) ; wrerr = 1 <S2SV_ModEnd> ; } } <S2SV_ModStart>!= 0 &&! wrerr <S2SV_ModEnd> && atomicio ( <S2SV_ModStart> count ) { note_err ( "%s: <S2SV_blank> %s", np, strerror ( errno ) ) ; wrerr = 1 ; } if (! wrerr <S2SV_ModEnd> && (! <S2SV_ModStart>!= 0 ) note_err <S2SV_ModEnd> ( "%s: <S2SV_blank> truncate: <S2SV_blank> %s", <S2SV_ModStart> ) ) ; <S2SV_ModEnd> if ( pflag <S2SV_ModStart> { # endif note_err <S2SV_ModEnd> ( "%s: <S2SV_blank> set <S2SV_blank> mode: <S2SV_blank> %s", <S2SV_ModStart> errno ) ) <S2SV_ModEnd> ; } } <S2SV_ModStart> { # endif note_err <S2SV_ModEnd> ( "%s: <S2SV_blank> set <S2SV_blank> mode: <S2SV_blank> %s", <S2SV_ModStart> errno ) ) <S2SV_ModEnd> ; } } <S2SV_ModStart> - 1 ) note_err ( np, "%s: <S2SV_blank> close: <S2SV_blank> %s", np, strerror ( errno ) ) ; <S2SV_ModEnd> (
Buggy code:
 void DefragRegisterTests ( void ) { # ifdef UNITTESTS UtRegisterTest ( "DefragInOrderSimpleTest", DefragInOrderSimpleTest ) ; UtRegisterTest ( "DefragReverseSimpleTest", DefragReverseSimpleTest ) ; UtRegisterTest ( "DefragSturgesNovakBsdTest", DefragSturgesNovakBsdTest ) ; UtRegisterTest ( "DefragSturgesNovakLinuxTest", DefragSturgesNovakLinuxTest ) ; UtRegisterTest ( "DefragSturgesNovakWindowsTest", DefragSturgesNovakWindowsTest ) ; UtRegisterTest ( "DefragSturgesNovakSolarisTest", DefragSturgesNovakSolarisTest ) ; UtRegisterTest ( "DefragSturgesNovakFirstTest", DefragSturgesNovakFirstTest ) ; UtRegisterTest ( "DefragSturgesNovakLastTest", DefragSturgesNovakLastTest ) ; UtRegisterTest ( "DefragIPv4NoDataTest", DefragIPv4NoDataTest ) ; UtRegisterTest ( "DefragIPv4TooLargeTest", DefragIPv4TooLargeTest ) ; UtRegisterTest ( "IPV6DefragInOrderSimpleTest", IPV6DefragInOrderSimpleTest ) ; UtRegisterTest ( "IPV6DefragReverseSimpleTest", IPV6DefragReverseSimpleTest ) ; UtRegisterTest ( "IPV6DefragSturgesNovakBsdTest", IPV6DefragSturgesNovakBsdTest ) ; UtRegisterTest ( "IPV6DefragSturgesNovakLinuxTest", IPV6DefragSturgesNovakLinuxTest ) ; UtRegisterTest ( "IPV6DefragSturgesNovakWindowsTest", IPV6DefragSturgesNovakWindowsTest ) ; UtRegisterTest ( "IPV6DefragSturgesNovakSolarisTest", IPV6DefragSturgesNovakSolarisTest ) ; UtRegisterTest ( "IPV6DefragSturgesNovakFirstTest", IPV6

Fix:
<S2SV_ModStart> DefragMfIpv6Test ) ; UtRegisterTest ( "DefragTestBadProto", DefragTestBadProto ) ;
Buggy code:
 int mi_repair_by_sort ( MI_CHECK * param, register MI_INFO * info, <START_BUG> const char * name, int rep_quick ) <END_BUG> { int got_error ; uint i ; ulong length ; ha_rows start_records ; my_off_t new_header_length, del ; File new_file ; MI_SORT_PARAM sort_param ; MYISAM_SHARE * share = info -> s ; HA_KEYSEG * keyseg ; ulong * rec_per_key_part ; char llbuff [ 22 ] ; SORT_INFO sort_info ; ulonglong UNINIT_VAR ( key_map ) ; DBUG_ENTER ( "mi_repair_by_sort" ) ; start_records = info -> state -> records ; got_error = 1 ; new_file = - 1 ; new_header_length = ( param -> testflag & T_UNPACK )? 0 : share -> pack. header_length ; if (! ( param -> testflag & T_SILENT ) ) { printf ( "-   recovering   (with   sort)   MyISAM-table   \'%s\'\\n", name ) ; printf ( "Data   records:   %s\\n", llstr ( start_records, llbuff ) ) ; } param -> testflag |= T_REP ; if ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) param -> testflag |= T_CALC_CHECKSUM ; bzero ( ( char * ) & sort_info, sizeof ( sort_info ) ) ; bzero ( ( char * ) & sort_param, sizeof ( sort_param ) ) ; if (! ( sort_info. key_block = alloc_key_blocks ( param, ( uint ) param -> sort_key_blocks, share -> base. max_key_block_length ) ) || init_io_cache ( & param -> read_cache, info -> dfile, ( uint ) param -> read_buffer_length, READ_CACHE, share -> pack. header_length, 1, MYF ( MY_WME ) ) || (! rep_quick && init_io_cache ( & info -> rec_cache, info -> dfile, ( uint ) param -> write_buffer_

Fix:
<S2SV_ModStart>, int rep_quick, my_bool no_copy_stat <S2SV_ModStart> 0 ) { myf flags = 0 ; if ( param -> testflag & T_BACKUP_DATA ) flags |= MY_REDEL_MAKE_BACKUP ; if ( no_copy_stat ) flags |= MY_REDEL_NO_COPY_STAT ; <S2SV_ModStart>, DATA_TMP_EXT, flags <S2SV_ModEnd> ) || mi_open_datafile
Buggy code:
 static int8_t sn_coap_parser_options_parse ( struct coap_s * handle, uint8_t * * packet_data_pptr, sn_coap_hdr_s * dst_coap_msg_ptr, uint8_t * packet_data_start_ptr, uint16_t packet_len ) { uint8_t previous_option_number = 0 ; int8_t ret_status = 0 ; uint16_t message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr, packet_data_start_ptr, packet_len, 0 ) ; dst_coap_msg_ptr -> token_len = * packet_data_start_ptr & COAP_HEADER_TOKEN_LENGTH_MASK ; if ( dst_coap_msg_ptr -> token_len ) { int8_t ptr_check_result ; if ( ( dst_coap_msg_ptr -> token_len > 8 ) || dst_coap_msg_ptr -> token_ptr ) { tr_error ( "sn_coap_parser_options_parse   -   token   not   valid!" ) ; return - 1 ; } ptr_check_result = sn_coap_parser_check_packet_ptr ( * packet_data_pptr, packet_data_start_ptr, packet_len, dst_coap_msg_ptr -> token_len ) ; if ( 0!= ptr_check_result ) { tr_error ( "sn_coap_parser_options_parse   -   **packet_data_pptr   overflow  !" ) ; return - 1 ; } dst_coap_msg_ptr -> token_ptr = sn_coap_protocol_malloc_copy ( handle, * packet_data_pptr, dst_coap_msg_ptr -> token_len ) ; if ( dst_coap_msg_ptr -> token_ptr == NULL ) { tr_error ( "sn_coap_parser_options_parse   -   failed   to   allocate   token!" ) ; return - 1 ; } message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr, packet_data_start_ptr, packet_len, dst_coap_

Fix:
<S2SV_ModStart> 1 ; } if ( sn_coap_parser_add_u16_limit ( option_number, previous_option_number, & option_number )!= 0 ) { return - 1 ; } <S2SV_ModEnd> option_parse_result = parse_ext_option <S2SV_ModStart> case COAP_OPTION_ETAG : if ( dst_coap_msg_ptr -> options_list_ptr -> etag_ptr ) { tr_error ( "sn_coap_parser_options_parse <S2SV_blank> - <S2SV_blank> COAP_OPTION_ETAG <S2SV_blank> exists!" ) ; return - 1 ; } <S2SV_ModStart> case COAP_OPTION_LOCATION_QUERY : if ( dst_coap_msg_ptr -> options_list_ptr -> location_query_ptr ) { tr_error ( "sn_coap_parser_options_parse <S2SV_blank> - <S2SV_blank> COAP_OPTION_LOCATION_QUERY <S2SV_blank> exists!" ) ; return - 1 ; } <S2SV_ModStart> case COAP_OPTION_URI_PATH : if ( dst_coap_msg_ptr -> uri_path_ptr ) { tr_error ( "sn_coap_parser_options_parse <S2SV_blank> - <S2SV_blank> COAP_OPTION_URI_PATH <S2SV_blank> exists!" ) ;
Buggy code:
 STATIC_OVL void escapes ( cp, tp ) const char * cp ; char * tp ; { <START_BUG> while ( * cp ) { <END_BUG> int cval = 0, meta = 0 ; if ( * cp == '\\\\' && cp [ 1 ] && index ( "mM", cp [ 1 ] ) && cp [ 2 ] ) { meta = 1 ; cp += 2 ; } if ( * cp == '\\\\' && cp [ 1 ] && index ( "0123456789xXoO", cp [ 1 ] ) && cp [ 2 ] ) {  NEARDATA const char hex [ ] = "00112233445566778899aAbBcCdDeEfF" ; <START_BUG> const char * dp ; <END_BUG> int dcount = 0 ;  <START_BUG> cp ++ ; <END_BUG>  if ( * cp == 'x' || * cp == 'X' ) <START_BUG> <END_BUG> for ( ++ cp ; * cp && ( dp = index ( hex, * cp ) ) && ( dcount ++ < 2 ) ; cp ++ )  cval = ( cval * 16 ) + ( ( int ) ( dp - hex ) // 2 ) ; <START_BUG> else if ( * cp == 'o' || * cp == 'O' ) <END_BUG> for ( ++ cp ; * cp && ( index ( "01234567", * cp ) ) && ( dcount ++ < 3 ) ; cp ++ ) cval = ( cval * 8 ) + ( * cp - '0' ) ; else for ( ; * cp && ( index ( "0123456789", * cp ) ) && ( dcount ++ < 3 ) ; cp ++ ) cval = ( cval * 10 ) + ( * cp - '0' ) ; } else if ( * cp == '\\\\' && cp [ 1 ] ) { switch ( * ++ cp ) { case '\\\\' : cval = '\\\\' ; break ; case 'n' : cval = '\\n' ; break ; case 't' : cval = '\\t' ; break ; case 'b' : cval = '\\b' ; break ; case 'r' : cval = '\\r' ; break ; default : cval = * cp ; }  cp ++ ; <START_BUG> } else if ( * cp == '^' && cp [ 1 ] ) { cval = ( * ++ cp & 0x1f ) ; cp ++ ; } else cval = * cp ++ ; if ( meta ) c<END_BUG>

Fix:
<S2SV_ModStart> tp ; { static <S2SV_ModEnd> NEARDATA const char <S2SV_ModStart> NEARDATA const char oct [ ] = "01234567", dec [ ] = "0123456789", <S2SV_ModStart> dp ; int cval, meta, dcount ; while ( * cp ) { meta = ( * cp == '\\\\' && ( cp [ 1 ] =='m' || cp [ 1 ] == 'M' ) && cp [ 2 ] ) ; if ( meta ) cp += 2 ; cval = dcount <S2SV_ModEnd> = 0 ; <S2SV_ModStart> = 0 ; if ( ( * cp!= '\\\\' && * cp!= '^' ) ||! cp [ 1 ] ) { cval = * cp ++ ; } else if ( * cp == '^' ) { cval = ( * ++ cp & 0x1f ) ; ++ cp ; } else if ( index ( dec, cp [ 1 ] ) ) { ++ cp ; do { cval = ( cval * 10 ) + ( * cp - '0' ) ; } while ( * ++ cp && index ( dec, * cp ) && ++ dcount < 3 ) ; } else if ( ( cp [ 1 ] == 'o' || cp [ 1 ] == 'O' ) && cp [ 2 ] && index (
Buggy code:
 error_t ksz8851Init ( NetInterface * interface ) { Ksz8851Context * context ; context = ( Ksz8851Context * ) interface -> nicContext ; TRACE_INFO ( "Initializing   KSZ8851   Ethernet   controller...\\r\\n" ) ; # if ( KSZ8851_SPI_SUPPORT == ENABLED ) interface -> spiDriver -> init ( ) ; # endif interface -> extIntDriver -> init ( ) ; <START_BUG> TRACE_DEBUG ( "CIDER=0x%04" PRIX16 "\\r\\n", ksz8851ReadReg ( interface, KSZ8851_REG_CIDER ) ) ; <END_BUG>  TRACE_DEBUG ( "PHY1ILR=0x%04" PRIX16 "\\r\\n", ksz8851ReadReg ( interface, KSZ8851_REG_PHY1ILR ) ) ; <START_BUG> <END_BUG> TRACE_DEBUG ( "PHY1IHR=0x%04" PRIX16 "\\r\\n", ksz8851ReadReg ( interface, KSZ8851_REG_PHY1IHR ) ) ;  <START_BUG> if ( ksz8851ReadReg ( interface, KSZ8851_REG_CIDER )!= KSZ8851_REV_A3_ID ) <END_BUG> { return ERROR_WRONG_IDENTIFIER ; } ksz8851DumpReg ( interface ) ; context -> frameId = 0 ; context -> txBuffer = memPoolAlloc ( ETH_MAX_FRAME_SIZE ) ; context -> rxBuffer = memPoolAlloc ( ETH_MAX_FRAME_SIZE ) ; if ( context -> txBuffer == NULL || context -> rxBuffer == NULL ) { memPoolFree ( context -> txBuffer ) ; memPoolFree ( context -> rxBuffer ) ; return ERROR_OUT_OF_MEMORY ; }  ksz8851WriteReg ( interface, KSZ8851_REG_MARH, htons ( interface -> macAddr. w [ 0 ] ) ) ; <START_BUG> <END_BUG> ksz8851WriteReg ( interface, KSZ8851_REG_MARM, htons ( interface -> macAddr. w [ 1 ] ) ) ;  <START_BUG> ksz8851WriteReg ( interface, KSZ8851_REG_MARL, htons ( interface -> macAddr. w [ 2 ] ) ) ; <END_BUG> 

Fix:
<S2SV_ModStart> ( interface, KSZ8851_CIDER <S2SV_ModEnd> ) ) ; <S2SV_ModStart> ( interface, KSZ8851_PHY1ILR <S2SV_ModEnd> ) ) ; <S2SV_ModStart> ( interface, KSZ8851_PHY1IHR <S2SV_ModEnd> ) ) ; <S2SV_ModStart> ( interface, KSZ8851_CIDER )!= ( KSZ8851_CIDER_FAMILY_ID_DEFAULT | KSZ8851_CIDER_CHIP_ID_DEFAULT | KSZ8851_CIDER_REV_ID_A3 ) <S2SV_ModEnd> ) { return <S2SV_ModStart> ( interface, KSZ8851_MARH <S2SV_ModEnd>, htons ( <S2SV_ModStart> ( interface, KSZ8851_MARM <S2SV_ModEnd>, htons ( <S2SV_ModStart> ( interface, KSZ8851_MARL <S2SV_ModEnd>, htons ( <S2SV_ModStart> ( interface, KSZ8851_TXCR, KSZ8851_TXCR_TXFCE | KSZ8851_TXCR_TXPE | KSZ8851_TXCR_TXCE ) ; ksz8851WriteReg ( interface, KSZ8851_TXFDPR, KSZ8851_TXFDPR_TXFPAI ) ; ksz8851WriteReg ( interface
Buggy code:
 vpx_codec_err_t vpx_codec_enc_init_ver ( vpx_codec_ctx_t * ctx, vpx_codec_iface_t * iface, <START_BUG> vpx_codec_enc_cfg_t * cfg, <END_BUG> vpx_codec_flags_t flags, int ver ) { vpx_codec_err_t res ; if ( ver!= VPX_ENCODER_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if (! ctx ||! iface ||! cfg ) res = VPX_CODEC_INVALID_PARAM ; else if ( iface -> abi_version!= VPX_CODEC_INTERNAL_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if (! ( iface -> caps & VPX_CODEC_CAP_ENCODER ) ) res = VPX_CODEC_INCAPABLE ;  else if ( ( flags & VPX_CODEC_USE_XMA ) &&! ( iface -> caps & VPX_CODEC_CAP_XMA ) ) <START_BUG> res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_PSNR ) &&! ( iface -> caps & VPX_CODEC_CAP_PSNR ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_OUTPUT_PARTITION ) &&! ( iface -> caps & VPX_CODEC_CAP_OUTPUT_PARTITION ) ) res = VPX_CODEC_INCAPABLE ; else { ctx -> iface = iface ; ctx -> name = iface -> name ; ctx -> priv = NULL ; ctx -> init_flags = flags ; ctx -> config. enc = cfg ; res = ctx -> iface -> init ( ctx, NULL ) ; if ( res ) { ctx -> err_detail = ctx -> priv? ctx -> priv -> err_detail : NULL ; vpx_codec_destroy ( ctx ) ; } <END_BUG> if ( ctx -> priv )  ctx -> priv -> iface = ctx -> iface ; } return SAVE_STATUS ( ctx, res ) ; }

Fix:
<S2SV_ModStart> * iface, const <S2SV_ModStart> ( flags & <S2SV_ModEnd> VPX_CODEC_USE_PSNR ) && <S2SV_ModStart> ) ; } <S2SV_ModEnd> } return SAVE_STATUS
Buggy code:
 void vp9_pick_filter_level ( const YV12_BUFFER_CONFIG * sd, VP9_COMP * cpi, LPF_PICK_METHOD method ) { VP9_COMMON * const cm = & cpi -> common ; struct loopfilter * const lf = & cm -> lf ; lf -> sharpness_level = cm -> frame_type == KEY_FRAME? 0 : cpi -> oxcf. sharpness ; <START_BUG> if ( method == LPF_PICK_FROM_Q ) { <END_BUG> const int min_filter_level = 0 ; const int max_filter_level = get_max_filter_level ( cpi ) ;  const int q = vp9_ac_quant ( cm -> base_qindex, 0 ) ; <START_BUG> <END_BUG> int filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 1015158, 18 ) ;  if ( cm -> frame_type == KEY_FRAME ) filt_guess -= 4 ; lf -> filter_level = clamp ( filt_guess, min_filter_level, max_filter_level ) ; } else { <START_BUG> search_filter_level ( sd, cpi, method == LPF_PICK_FROM_SUBIMAGE ) ; <END_BUG> } }

Fix:
<S2SV_ModStart> ( method == LPF_PICK_MINIMAL_LPF && lf -> filter_level ) { lf -> filter_level = 0 ; } else if ( method >= <S2SV_ModStart> base_qindex, 0, cm -> bit_depth ) ; # if CONFIG_VP9_HIGHBITDEPTH int filt_guess ; switch ( cm -> bit_depth ) { case VPX_BITS_8 : <S2SV_ModEnd> filt_guess = ROUND_POWER_OF_TWO <S2SV_ModStart> 18 ) ; break ; case VPX_BITS_10 : filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 4060632, 20 ) ; break ; case VPX_BITS_12 : filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 16242526, 22 ) ; break ; default : assert ( 0 && "bit_depth <S2SV_blank> should <S2SV_blank> be <S2SV_blank> VPX_BITS_8, <S2SV_blank> VPX_BITS_10 <S2SV_blank> " "or <S2SV_blank> VPX_BITS_12" ) ; return ; } # else int filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 1015
Buggy code:
 static int rawv6_sendmsg ( struct sock * sk, struct msghdr * msg, size_t len ) <START_BUG> { <END_BUG> struct ipv6_txoptions opt_space ; DECLARE_SOCKADDR ( struct sockaddr_in6 *, sin6, msg -> msg_name ) ; struct in6_addr * daddr, * final_p, final ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct raw6_sock * rp = raw6_sk ( sk ) ; struct ipv6_txoptions * opt = NULL ; struct ip6_flowlabel * flowlabel = NULL ; struct dst_entry * dst = NULL ; struct raw6_frag_vec rfv ; struct flowi6 fl6 ; int addr_len = msg -> msg_namelen ; int hlimit = - 1 ; int tclass = - 1 ; int dontfrag = - 1 ; u16 proto ; int err ; if ( len > INT_MAX ) return - EMSGSIZE ; if ( msg -> msg_flags & MSG_OOB ) return - EOPNOTSUPP ; memset ( & fl6, 0, sizeof ( fl6 ) ) ; fl6. flowi6_mark = sk -> sk_mark ; if ( sin6 ) { if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( sin6 -> sin6_family && sin6 -> sin6_family!= AF_INET6 ) return - EAFNOSUPPORT ; proto = ntohs ( sin6 -> sin6_port ) ; if (! proto ) proto = inet -> inet_num ; else if ( proto!= inet -> inet_num ) return - EINVAL ; if ( proto > 255 ) return - EINVAL ; daddr = & sin6 -> sin6_addr ; if ( np -> sndflow ) { fl6. flowlabel = sin6 -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; if ( fl6. flowlabel & IPV6_FLOWLABEL_MASK ) { flowlabel = fl6_sock_lookup ( sk, fl6. flowlabel ) ; if (! flowlabel ) return - EINVAL ; } } if ( sk -> sk_state == TCP_ESTABLISH

Fix:
<S2SV_ModStart> len ) { struct ipv6_txoptions * opt_to_free = NULL ; <S2SV_ModStart>! opt ) { opt = txopt_get ( np ) ; opt_to_free = opt ; } <S2SV_ModEnd> if ( flowlabel <S2SV_ModStart> flowlabel ) ; txopt_put ( opt_to_free ) ;
Buggy code:
 int cib_connect ( gboolean full ) { int rc = pcmk_ok ; static gboolean need_pass = TRUE ; CRM_CHECK ( cib!= NULL, return - EINVAL ) ; if ( getenv ( "CIB_passwd" )!= NULL ) { need_pass = FALSE ; } if ( watch_fencing && st == NULL ) { st = stonith_api_new ( ) ; } if ( watch_fencing && st -> state == stonith_disconnected ) { crm_trace ( "Connecting   to   stonith" ) ; rc = st -> cmds -> connect ( st, crm_system_name, NULL ) ; if ( rc == pcmk_ok ) { crm_trace ( "Setting   up   stonith   callbacks" ) ; st -> cmds -> register_notification ( st, T_STONITH_NOTIFY_FENCE, mon_st_callback ) ; } } if ( cib -> state!= cib_connected_query && cib -> state!= cib_connected_command ) { crm_trace ( "Connecting   to   the   CIB" ) ; if ( as_console && need_pass && cib -> variant == cib_remote ) { need_pass = FALSE ; print_as ( "Password:" ) ; } rc = cib -> cmds -> signon ( cib, crm_system_name, cib_query ) ; if ( rc!= pcmk_ok ) { return rc ; } current_cib = get_cib_copy ( cib ) ; mon_refresh_display ( NULL ) ; if ( full ) { if ( rc == pcmk_ok ) { rc = cib -> cmds -> set_connection_dnotify ( cib, mon_cib_connection_destroy ) ; if ( rc == - EPROTONOSUPPORT ) { <START_BUG> print_as ( "Notification   setup   failed,   won\'t   be   able   to   reconnect   after   failure" ) ; <END_BUG> if ( as_console ) { sleep ( 2 ) ; } rc = pcmk_ok ; } } if ( rc == pcmk_ok ) { cib -> cmds -> del_notify_callback ( cib, T_CIB_DIFF_NOTIFY, crm_diff_update )

Fix:
<S2SV_ModStart> { print_as ( "Notification <S2SV_blank> setup <S2SV_blank> not <S2SV_blank> supported, <S2SV_blank> won\'t <S2SV_blank> be <S2SV_blank> able <S2SV_blank> to <S2SV_blank> reconnect <S2SV_blank> after <S2SV_blank> failure" <S2SV_ModEnd> ) ; if
Buggy code:
 static void setup_connection ( GsmXSMPClient * client ) { GIOChannel * channel ; int fd ; g_debug ( "GsmXSMPClient:   Setting   up   new   connection" ) ; fd = IceConnectionNumber ( client -> priv -> ice_connection ) ; fcntl ( fd, F_SETFD, fcntl ( fd, F_GETFD, 0 ) | FD_CLOEXEC ) ; channel = g_io_channel_unix_new ( fd ) ; client -> priv -> watch_id = g_io_add_watch ( channel, G_IO_IN | G_IO_ERR, ( GIOFunc ) client_iochannel_watch, client ) ; g_io_channel_unref ( channel ) ; <START_BUG> client -> priv -> protocol_timeout = g_timeout_add_seconds ( 5, <END_BUG> ( GSourceFunc ) _client_protocol_timeout, client ) ; set_description ( client ) ; g_debug ( "GsmXSMPClient:   New   client   \'%s\'", client -> priv -> description ) ; }

Fix:
<S2SV_ModStart> channel ) ; <S2SV_ModEnd> set_description ( client
Buggy code:
 <START_BUG> static void write_intra_mode ( vp9_writer * w, MB_PREDICTION_MODE mode, <END_BUG>  const vp9_prob * probs ) { <START_BUG> vp9_write_token ( w, vp9_intra_mode_tree, probs, & intra_mode_encodings [ mode ] ) ; }<END_BUG>

Fix:
<S2SV_ModStart> void write_intra_mode ( vpx_writer <S2SV_ModEnd> * w, <S2SV_ModStart> * w, PREDICTION_MODE <S2SV_ModEnd> mode, const <S2SV_ModStart> mode, const vpx_prob <S2SV_ModEnd> * probs )