nus-yam/ex-repair huggingface dataset:
Buggy code:
 static int parse_packet ( sockent_t * se, void * buffer, size_t buffer_size, int flags, const char * username ) { int status ; value_list_t vl = VALUE_LIST_INIT ; notification_t n ; # if HAVE_LIBGCRYPT int packet_was_signed = ( flags & PP_SIGNED ) ; int packet_was_encrypted = ( flags & PP_ENCRYPTED ) ; int printed_ignore_warning = 0 ; # endif memset ( & vl, '\\0', sizeof ( vl ) ) ; memset ( & n, '\\0', sizeof ( n ) ) ; status = 0 ; while ( ( status == 0 ) && ( 0 < buffer_size ) && ( ( unsigned int ) buffer_size > sizeof ( part_header_t ) ) ) { uint16_t pkg_length ; uint16_t pkg_type ; memcpy ( ( void * ) & pkg_type, ( void * ) buffer, sizeof ( pkg_type ) ) ; memcpy ( ( void * ) & pkg_length, ( void * ) ( buffer + sizeof ( pkg_type ) ), sizeof ( pkg_length ) ) ; pkg_length = ntohs ( pkg_length ) ; pkg_type = ntohs ( pkg_type ) ; if ( pkg_length > buffer_size ) break ; if ( pkg_length < ( 2 * sizeof ( uint16_t ) ) ) break ; if ( pkg_type == TYPE_ENCR_AES256 ) { status = parse_part_encr_aes256 ( se, & buffer, & buffer_size, flags ) ; if ( status!= 0 ) { ERROR ( "network   plugin:   Decrypting   AES256   " "part   failed   " "with   status   %i.", status ) ; break ; } } # if HAVE_LIBGCRYPT else if ( ( se -> data. server. security_level == SECURITY_LEVEL_ENCRYPT ) && ( packet_was_encrypted == 0 ) ) { if ( printed_ignore_warning == 0 ) { INFO ( "network   plugin:   Unencrypted   packet   or   " "part   has   been   ignored." ) ; printed_ignore_warning = 1 ; } buffer = ( ( char * ) buffer ) + pkg_length ; <START_BUG> continue ;<END_BUG>

Fix:
<S2SV_ModStart> + pkg_length ; buffer_size -= ( size_t ) pkg_length ; <S2SV_ModStart> + pkg_length ; buffer_size -= ( size_t ) pkg_length ; <S2SV_ModStart> + pkg_length ; buffer_size -= ( size_t ) pkg_length ;
Buggy code:
 node * Ta3Parser_ParseStringObject ( const char * s, PyObject * filename, grammar * g, int start, perrdetail * err_ret, int * flags ) { struct tok_state * tok ; int exec_input = start == file_input ; if ( initerr ( err_ret, filename ) < 0 ) return NULL ; if ( * flags & PyPARSE_IGNORE_COOKIE ) tok = Ta3Tokenizer_FromUTF8 ( s, exec_input ) ; else tok = Ta3Tokenizer_FromString ( s, exec_input ) ; if ( tok == NULL ) { err_ret -> error = PyErr_Occurred ( )? E_DECODE : E_NOMEM ; return NULL ; } # ifndef PGEN Py_INCREF ( err_ret -> filename ) ; tok -> filename = err_ret -> filename ; # endif <START_BUG> return parsetok ( tok, g, start, err_ret, flags ) ; <END_BUG> }

Fix:
<S2SV_ModStart> ; # endif if ( * flags & PyPARSE_ASYNC_ALWAYS ) tok -> async_always = 1 ;
Buggy code:
 <START_BUG> void <END_BUG> pci_populate_msicap ( struct msicap * msicap, int msgnum, int nextptr ) { int mmc ;  assert ( ( msgnum & ( msgnum - 1 ) ) == 0 && msgnum >= 1 && msgnum <= 32 ) ; <START_BUG> mmc = ffs ( msgnum ) - 1 ; bzero ( msicap, sizeof ( struct msicap ) ) ; msicap -> capid = PCIY_MSI ; msicap -> nextptr = nextptr ; msicap -> msgctrl = PCIM_MSICTRL_64BIT | ( mmc << 1 ) ; <END_BUG> } 

Fix:
<S2SV_ModStart> <S2SV_null> <S2SV_null> <S2SV_null> int <S2SV_ModEnd> pci_populate_msicap ( struct <S2SV_ModStart> int mmc ; if ( <S2SV_ModEnd> ( ( msgnum <S2SV_ModStart> 1 ) )!= 0 ) || msgnum < 1 || msgnum > 32 ) { pr_err ( "%s: <S2SV_blank> invalid <S2SV_blank> number <S2SV_blank> of <S2SV_blank> msi <S2SV_blank> messages!\\n", __func__ ) ; return - 1 ; } <S2SV_ModEnd> mmc = ffs <S2SV_ModStart> 1 ) ; return 0 ;
Buggy code:
 int blkcg_init_queue ( struct request_queue * q ) { struct blkcg_gq * new_blkg, * blkg ; bool preloaded ; int ret ; new_blkg = blkg_alloc ( & blkcg_root, q, GFP_KERNEL ) ; if (! new_blkg ) return - ENOMEM ; preloaded =! radix_tree_preload ( GFP_KERNEL ) ; rcu_read_lock ( ) ; spin_lock_irq ( q -> queue_lock ) ; blkg = blkg_create ( & blkcg_root, q, new_blkg ) ; spin_unlock_irq ( q -> queue_lock ) ; rcu_read_unlock ( ) ; if ( preloaded ) radix_tree_preload_end ( ) ; <START_BUG> if ( IS_ERR ( blkg ) ) { <END_BUG> blkg_free ( new_blkg ) ; return PTR_ERR ( blkg ) ;  } <START_BUG> q -> root_blkg = blkg ; q -> root_rl. blkg = blkg ; ret = blk_throtl_init ( q ) ; if ( ret ) { spin_lock_irq ( q -> queue_lock ) ; blkg_destroy_all ( q ) ; spin_unlock_irq ( q -> queue_lock ) ; } return ret ; }<END_BUG>

Fix:
<S2SV_ModStart> blkg ) ) <S2SV_ModEnd> return PTR_ERR ( <S2SV_ModStart> blkg ) ; <S2SV_ModEnd> q -> root_blkg
Buggy code:
 static void cp2112_gpio_set ( struct gpio_chip * chip, unsigned offset, int value ) { struct cp2112_device * dev = gpiochip_get_data ( chip ) ; struct hid_device * hdev = dev -> hdev ; u8 * buf = dev -> in_out_buffer ; <START_BUG> unsigned long flags ; <END_BUG> int ret ;  spin_lock_irqsave ( & dev -> lock, flags ) ; <START_BUG> buf [ 0 ] = CP2112_GPIO_SET ; buf [ 1 ] = value? 0xff : 0 ; buf [ 2 ] = 1 << offset ; ret = hid_hw_raw_request ( hdev, CP2112_GPIO_SET, buf, CP2112_GPIO_SET_LENGTH, HID_FEATURE_REPORT, HID_REQ_SET_REPORT ) ; if ( ret < 0 ) hid_err ( hdev, "error   setting   GPIO   values:   %d\\n", ret ) ; <END_BUG> spin_unlock_irqrestore ( & dev -> lock, flags ) ;  }

Fix:
<S2SV_ModStart> -> in_out_buffer ; <S2SV_ModEnd> int ret ; <S2SV_ModStart> int ret ; mutex_lock <S2SV_ModEnd> ( & dev <S2SV_ModStart> dev -> lock <S2SV_ModEnd> ) ; buf <S2SV_ModStart> ret ) ; mutex_unlock <S2SV_ModEnd> ( & dev <S2SV_ModStart> dev -> lock <S2SV_ModEnd> ) ; }
Buggy code:
 int handle_nsExtendConfigTable ( netsnmp_mib_handler * handler, netsnmp_handler_registration * reginfo, netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests ) { netsnmp_request_info * request ; netsnmp_table_request_info * table_info ; netsnmp_extend * extension ; extend_registration_block * eptr ; int i ; int need_to_validate = 0 ; for ( request = requests ; request ; request = request -> next ) { if ( request -> processed ) continue ; table_info = netsnmp_extract_table_info ( request ) ; extension = ( netsnmp_extend * ) netsnmp_extract_table_row_data ( request ) ; DEBUGMSGTL ( ( "nsExtendTable:config", "varbind:   " ) ) ; DEBUGMSGOID ( ( "nsExtendTable:config", request -> requestvb -> name, request -> requestvb -> name_length ) ) ; DEBUGMSG ( ( "nsExtendTable:config", "   (%s)\\n", se_find_label_in_slist ( "agent_mode", reqinfo -> mode ) ) ) ; switch ( reqinfo -> mode ) { case MODE_GET : switch ( table_info -> colnum ) { case COLUMN_EXTCFG_COMMAND : snmp_set_var_typed_value ( request -> requestvb, ASN_OCTET_STR, extension -> command, ( extension -> command )? strlen ( extension -> command ) : 0 ) ; break ; case COLUMN_EXTCFG_ARGS : snmp_set_var_typed_value ( request -> requestvb, ASN_OCTET_STR, extension -> args, ( extension -> args )? strlen ( extension -> args ) : 0 ) ; break ; case COLUMN_EXTCFG_INPUT : snmp_set_var_typed_value ( request -> requestvb, ASN_OCTET_STR, extension -> input, ( extension -> input )? strlen ( extension -> input ) : 0 ) ; break ; case COLUMN_EXTCFG_CACHETIME : snmp_set_var_typed_value ( request -> requestvb, ASN_INTEGER, ( u_char * ) & extension -> cache -> timeout, sizeof ( int )

Fix:
<S2SV_ModStart> break ; # if! defined ( NETSNMP_NO_WRITE_SUPPORT ) && ENABLE_EXTEND_WRITE_ACCESS <S2SV_ModEnd> case MODE_SET_RESERVE1 : <S2SV_ModStart> } } # if! defined ( NETSNMP_NO_WRITE_SUPPORT ) && ENABLE_EXTEND_WRITE_ACCESS <S2SV_ModEnd> if ( need_to_validate
Buggy code:
 int imap_exec ( struct ImapAccountData * adata, const char * cmdstr, ImapCmdFlags flags ) { int rc ; <START_BUG> rc = cmd_start ( adata, cmdstr, flags ) ; <END_BUG> if ( rc < 0 ) { cmd_handle_fatal ( adata ) ; return IMAP_EXEC_FATAL ; } if ( flags & IMAP_CMD_QUEUE ) return IMAP_EXEC_SUCCESS ; if ( ( flags & IMAP_CMD_POLL ) && ( C_ImapPollTimeout > 0 ) && ( ( mutt_socket_poll ( adata -> conn, C_ImapPollTimeout ) ) == 0 ) ) { mutt_error ( _ ( "Connection   to   %s   timed   out" ), adata -> conn -> account. host ) ; cmd_handle_fatal ( adata ) ; return IMAP_EXEC_FATAL ; } mutt_sig_allow_interrupt ( true ) ; do { rc = imap_cmd_step ( adata ) ;  } while ( rc == IMAP_RES_CONTINUE ) ; <START_BUG> mutt_sig_allow_interrupt ( false ) ; if ( rc == IMAP_RES_NO ) return IMAP_EXEC_ERROR ; if ( rc!= IMAP_RES_OK ) { if ( adata -> status!= IMAP_FATAL ) return IMAP_EXEC_ERROR ; mutt_debug ( LL_DEBUG1, "command   failed:   %s\\n", adata -> buf ) ; return IMAP_EXEC_FATAL ; } return IMAP_EXEC_SUCCESS ; }<END_BUG>

Fix:
<S2SV_ModStart> int rc ; if ( flags & IMAP_CMD_SINGLE ) { if ( adata -> nextcmd!= adata -> lastcmd ) imap_exec ( adata, NULL, IMAP_CMD_POLL ) ; } <S2SV_ModStart> adata ) ; if ( ( flags & IMAP_CMD_SINGLE ) && ( adata -> nextcmd == adata -> lastcmd ) ) break ;
Buggy code:
 static void copy_asoundrc ( void ) { char * src = RUN_ASOUNDRC_FILE ; char * dest ; if ( asprintf ( & dest, "%s//.asoundrc", cfg. homedir ) == - 1 ) errExit ( "asprintf" ) ; if ( is_link ( dest ) ) { fprintf ( stderr, "Error:   %s   is   a   symbolic   link\\n", dest ) ; exit ( 1 ) ; } <START_BUG> pid_t child = fork ( ) ; <END_BUG> if ( child < 0 ) errExit ( "fork" ) ; if ( child == 0 ) { drop_privs ( 0 ) ; int rv = copy_file ( src, dest, getuid ( ), getgid ( ), S_IRUSR | S_IWUSR ) ;  if ( rv ) <START_BUG> fprintf ( stderr, "Warning:   cannot   transfer  .asoundrc   in   private   home   directory\\n" ) ; else { <END_BUG> fs_logger2 ( "clone", dest ) ;  } _exit ( 0 ) ; } waitpid ( child, NULL, 0 ) ; unlink ( src ) ; }

Fix:
<S2SV_ModStart> ) ; } copy_file_as_user <S2SV_ModEnd> ( src, <S2SV_ModStart> S_IWUSR ) ; <S2SV_ModEnd> fs_logger2 ( "clone" <S2SV_ModStart> "clone", dest <S2SV_ModEnd> ) ; unlink
Buggy code:
 void vp9_restore_layer_context ( VP9_COMP * const cpi ) { <START_BUG> LAYER_CONTEXT * const lc = get_layer_context ( & cpi -> svc ) ; <END_BUG> const int old_frame_since_key = cpi -> rc. frames_since_key ; const int old_frame_to_key = cpi -> rc. frames_to_key ; cpi -> rc = lc -> rc ; cpi -> twopass = lc -> twopass ; cpi -> oxcf. target_bandwidth = lc -> target_bandwidth ;  cpi -> oxcf. starting_buffer_level = lc -> starting_buffer_level ; <START_BUG> cpi -> oxcf. optimal_buffer_level = lc -> optimal_buffer_level ; cpi -> oxcf. maximum_buffer_size = lc -> maximum_buffer_size ; cpi -> output_framerate = lc -> framerate ; if ( cpi -> svc. number_temporal_layers > 1 ) { cpi -> rc. frames_since_key = old_frame_since_key ; cpi -> rc. frames_to_key = old_frame_to_key ; } }<END_BUG>

Fix:
<S2SV_ModStart> = get_layer_context ( cpi <S2SV_ModEnd> ) ; const <S2SV_ModStart> ; cpi -> alt_ref_source <S2SV_ModEnd> = lc -> <S2SV_ModStart> = lc -> alt_ref_source <S2SV_ModEnd> ; if (
Buggy code:
 <START_BUG> static int nfs4_intent_set_file ( struct nameidata * nd, struct path * path, struct nfs4_state * state ) <END_BUG> { struct file * filp ; int ret ;  if ( nd -> intent. open. flags & FMODE_EXEC ) { <START_BUG> ret = nfs_may_open ( state -> inode, state -> owner -> so_cred, nd -> intent. open. flags ) ; if ( ret < 0 ) goto out_close ; } filp = lookup_instantiate_filp ( nd, path -> dentry, NULL ) ; if (! IS_ERR ( filp ) ) { struct nfs_open_context * ctx ; ctx = nfs_file_open_context ( filp ) ; ctx -> state = state ; return 0 ; } ret = PTR_ERR ( filp ) ; out_close : <END_BUG> nfs4_close_sync ( path, state, nd -> intent. open. flags ) ;  return ret ; }

Fix:
<S2SV_ModStart> nfs4_state * state, fmode_t fmode <S2SV_ModStart> ; if ( fmode <S2SV_ModEnd> & FMODE_EXEC ) <S2SV_ModStart>, state, fmode & ( FMODE_READ | FMODE_WRITE ) <S2SV_ModEnd> ) ; return
Buggy code:
 void __detach_mounts ( struct dentry * dentry ) { struct mountpoint * mp ; struct mount * mnt ; namespace_lock ( ) ; mp = lookup_mountpoint ( dentry ) ; if (! mp ) goto out_unlock ; lock_mount_hash ( ) ; while (! hlist_empty ( & mp -> m_list ) ) { mnt = hlist_entry ( mp -> m_list. first, struct mount, mnt_mp_list ) ; <START_BUG> umount_tree ( mnt, 0 ) ; <END_BUG> } unlock_mount_hash ( ) ; put_mountpoint ( mp ) ; out_unlock : namespace_unlock ( ) ; }

Fix:
<S2SV_ModStart> mnt_mp_list ) ; if ( mnt -> mnt. mnt_flags & MNT_UMOUNT ) { struct mount * p, * tmp ; list_for_each_entry_safe ( p, tmp, & mnt -> mnt_mounts, mnt_child ) { hlist_add_head ( & p -> mnt_umount. s_list, & unmounted ) ; umount_mnt ( p ) ; } } else
Buggy code:
 void sctp_generate_heartbeat_event ( unsigned long data ) { int error = 0 ; struct sctp_transport * transport = ( struct sctp_transport * ) data ; struct sctp_association * asoc = transport -> asoc ; <START_BUG> struct net * net = sock_net ( asoc -> base. sk ) ; <END_BUG>  bh_lock_sock ( asoc -> base. sk ) ; <START_BUG> <END_BUG> if ( sock_owned_by_user ( asoc -> base. sk ) ) {  pr_debug ( "%s:   sock   is   busy\\n", __func__ ) ; if (! mod_timer ( & transport -> hb_timer, jiffies + ( HZ // 20 ) ) ) sctp_transport_hold ( transport ) ; goto out_unlock ; } if ( transport -> dead ) goto out_unlock ; error = sctp_do_sm ( net, SCTP_EVENT_T_TIMEOUT, SCTP_ST_TIMEOUT ( SCTP_EVENT_TIMEOUT_HEARTBEAT ), asoc -> state, asoc -> ep, asoc, transport, GFP_ATOMIC ) ; if ( error ) <START_BUG> asoc -> base. sk -> sk_err = - error ; <END_BUG> out_unlock :  bh_unlock_sock ( asoc -> base. sk ) ; <START_BUG> sctp_transport_put ( transport ) ; }<END_BUG>

Fix:
<S2SV_ModStart> asoc ; struct sock * sk = asoc -> base. sk ; struct <S2SV_ModStart> = sock_net ( <S2SV_ModEnd> sk ) ; <S2SV_ModStart> ; bh_lock_sock ( <S2SV_ModEnd> sk ) ; <S2SV_ModStart> ( sock_owned_by_user ( <S2SV_ModEnd> sk ) ) <S2SV_ModStart> ( error ) <S2SV_ModEnd> sk -> sk_err <S2SV_ModStart> : bh_unlock_sock ( <S2SV_ModEnd> sk ) ;
Buggy code:
 l_int32 gplotGenCommandFile ( GPLOT * gplot ) { <START_BUG> char buf [ L_BUF_SIZE ] ; <END_BUG> char * cmdstr, * plottitle, * dataname ; l_int32 i, plotstyle, nplots ; FILE * fp ; PROCNAME ( "gplotGenCommandFile" ) ; if (! gplot ) return ERROR_INT ( "gplot   not   defined", procName, 1 ) ; sarrayClear ( gplot -> cmddata ) ; if ( gplot -> title ) {  snprintf ( buf, L_BUF_SIZE, "set   title   \'%s\'", gplot -> title ) ; <START_BUG> sarrayAddString ( gplot -> cmddata, buf, L_COPY ) ; } if ( gplot -> xlabel ) { <END_BUG> snprintf ( buf, L_BUF_SIZE, "set   xlabel   \'%s\'", gplot -> xlabel ) ;  sarrayAddString ( gplot -> cmddata, buf, L_COPY ) ; } if ( gplot -> ylabel ) { <START_BUG> snprintf ( buf, L_BUF_SIZE, "set   ylabel   \'%s\'", gplot -> ylabel ) ; <END_BUG> sarrayAddString ( gplot -> cmddata, buf, L_COPY ) ; } if ( gplot -> outformat == GPLOT_PNG ) {  snprintf ( buf, L_BUF_SIZE, "set   terminal   png;   set   output   \'%s\'", <START_BUG> gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_PS ) { <END_BUG> snprintf ( buf, L_BUF_SIZE, "set   terminal   postscript;   set   output   \'%s\'",  gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_EPS ) { <START_BUG> snprintf ( buf, L_BUF_SIZE, <END_BUG> "set   terminal   postscript   eps;   set   output   \'%s\'", gplot -> outname ) ; } else if ( gplot -> outformat == GPLOT_LATEX ) {  snprintf ( buf, L_BUF_SIZE, "set   terminal   latex;   set   output   \'%

Fix:
<S2SV_ModStart> char buf [ L_BUFSIZE <S2SV_ModEnd> ] ; char <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> title <S2SV_blank> \'%s\'", <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> xlabel <S2SV_blank> \'%s\'", <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> ylabel <S2SV_blank> \'%s\'", <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> terminal <S2SV_blank> png; <S2SV_blank> set <S2SV_blank> output <S2SV_blank> \'%s\'", <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> terminal <S2SV_blank> postscript; <S2SV_blank> set <S2SV_blank> output <S2SV_blank> \'%s\'", <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> terminal <S2SV_blank> postscript <S2SV_blank> eps; <S2SV_blank> set <S2SV_blank> output <S2SV_blank> \'%s\'", <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> terminal <S2SV_blank> latex; <S2SV_blank> set <S2SV_blank> output <S2SV_blank> \'%s\'", <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> logscale <S2SV_blank> x" ) <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "set <S2SV_blank> logscale <S2SV_blank> y" ) <S2SV_ModStart> ( buf, L_BUFSIZE <S2SV_ModEnd>, "plot <S2SV_blank> \'
Buggy code:
 static int __ip6_datagram_connect ( struct sock * sk, struct sockaddr * uaddr, int addr_len ) { struct sockaddr_in6 * usin = ( struct sockaddr_in6 * ) uaddr ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * daddr, * final_p, final ; struct dst_entry * dst ; struct flowi6 fl6 ; struct ip6_flowlabel * flowlabel = NULL ; struct ipv6_txoptions * opt ; int addr_type ; int err ; if ( usin -> sin6_family == AF_INET ) { if ( __ipv6_only_sock ( sk ) ) return - EAFNOSUPPORT ; err = __ip4_datagram_connect ( sk, uaddr, addr_len ) ; goto ipv4_connected ; } if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( usin -> sin6_family!= AF_INET6 ) return - EAFNOSUPPORT ; memset ( & fl6, 0, sizeof ( fl6 ) ) ; if ( np -> sndflow ) { fl6. flowlabel = usin -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; if ( fl6. flowlabel & IPV6_FLOWLABEL_MASK ) { flowlabel = fl6_sock_lookup ( sk, fl6. flowlabel ) ; if (! flowlabel ) return - EINVAL ; } } addr_type = ipv6_addr_type ( & usin -> sin6_addr ) ; if ( addr_type == IPV6_ADDR_ANY ) { usin -> sin6_addr. s6_addr [ 15 ] = 0x01 ; } daddr = & usin -> sin6_addr ; if ( addr_type == IPV6_ADDR_MAPPED ) { struct sockaddr_in sin ; if ( __ipv6_only_sock ( sk ) ) { err = - ENETUNREACH ; goto out ; } sin. sin_family = AF_INET ; sin. sin_addr. s_addr = daddr -> s6_addr32 [ 3 ] ; sin. sin_port = usin -> sin

Fix:
<S2SV_ModStart> ) ) ; rcu_read_lock ( ) ; <S2SV_ModStart> -> opt : rcu_dereference ( <S2SV_ModStart> np -> opt ) <S2SV_ModStart>, & final ) ; rcu_read_unlock (
Buggy code:
 int ParseRiffHeaderConfig ( FILE * infile, char * infilename, char * fourcc, WavpackContext * wpc, WavpackConfig * config ) { int is_rf64 =! strncmp ( fourcc, "RF64", 4 ), got_ds64 = 0 ; int64_t total_samples = 0, infilesize ; RiffChunkHeader riff_chunk_header ; ChunkHeader chunk_header ; WaveHeader WaveHeader ; DS64Chunk ds64_chunk ; uint32_t bcount ; CLEAR ( WaveHeader ) ; CLEAR ( ds64_chunk ) ; infilesize = DoGetFileSize ( infile ) ; if (! is_rf64 && infilesize >= 4294967296LL &&! ( config -> qmode & QMODE_IGNORE_LENGTH ) ) { error_line ( "can\'t   handle  .WAV   files   larger   than   4   GB   (non-standard)!" ) ; return WAVPACK_SOFT_ERROR ; } memcpy ( & riff_chunk_header, fourcc, 4 ) ; if ( (! DoReadFile ( infile, ( ( char * ) & riff_chunk_header ) + 4, sizeof ( RiffChunkHeader ) - 4, & bcount ) || bcount!= sizeof ( RiffChunkHeader ) - 4 || strncmp ( riff_chunk_header. formType, "WAVE", 4 ) ) ) { error_line ( "%s   is   not   a   valid  .WAV   file!", infilename ) ; return WAVPACK_SOFT_ERROR ; } else if (! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) &&! WavpackAddWrapper ( wpc, & riff_chunk_header, sizeof ( RiffChunkHeader ) ) ) { error_line ( "%s", WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } while ( 1 ) { if (! DoReadFile ( infile, & chunk_header, sizeof ( ChunkHeader ), & bcount ) || bcount!= sizeof ( ChunkHeader ) ) { error_line ( "%s   is   not   a   valid  .WAV   file!", infilename ) ; return WAVPACK_

Fix:
<S2SV_ModStart> & ds64_chunk, sizeof ( DS64Chunk ) <S2SV_ModEnd>, & bcount <S2SV_ModStart> || bcount!= sizeof ( DS64Chunk ) <S2SV_ModEnd> ) { error_line <S2SV_ModStart> & ds64_chunk, sizeof ( DS64Chunk ) <S2SV_ModEnd> ) ) {
Buggy code:
 bool ExprResolveBoolean ( struct xkb_context * ctx, const ExprDef * expr, bool * set_rtrn ) { bool ok = false ; const char * ident ; switch ( expr -> expr. op ) { case EXPR_VALUE : if ( expr -> expr. value_type!= EXPR_TYPE_BOOLEAN ) { log_err ( ctx, "Found   constant   of   type   %s   where   boolean   was   expected\\n", expr_value_type_to_string ( expr -> expr. value_type ) ) ; return false ; } * set_rtrn = expr -> boolean. set ; return true ; case EXPR_IDENT : ident = xkb_atom_text ( ctx, expr -> ident. ident ) ; if ( ident ) { if ( istreq ( ident, "true" ) || istreq ( ident, "yes" ) || istreq ( ident, "on" ) ) { * set_rtrn = true ; return true ; } else if ( istreq ( ident, "false" ) || istreq ( ident, "no" ) || istreq ( ident, "off" ) ) { * set_rtrn = false ; return true ; } } log_err ( ctx, "Identifier   \\"%s\\"   of   type   boolean   is   unknown\\n", ident ) ; return false ; case EXPR_FIELD_REF : log_err ( ctx, "Default   \\"%s.%s\\"   of   type   boolean   is   unknown\\n", xkb_atom_text ( ctx, expr -> field_ref. element ), xkb_atom_text ( ctx, expr -> field_ref. field ) ) ; return false ; case EXPR_INVERT : case EXPR_NOT : <START_BUG> ok = ExprResolveBoolean ( ctx, expr, set_rtrn ) ; <END_BUG> if ( ok ) * set_rtrn =! * set_rtrn ; return ok ; case EXPR_ADD : case EXPR_SUBTRACT : case EXPR_MULTIPLY : case EXPR_DIVIDE : case EXPR_ASSIGN : case EXPR_NEGATE : case EXPR_UNARY_PLUS : log_err ( ctx, "%s   of   boolean   values   not   permitted\\n", expr_op_type

Fix:
<S2SV_ModStart> ctx, expr -> unary. child
Buggy code:
 int vp9_prob_diff_update_savings_search_model ( const unsigned int * ct, <START_BUG> const vp9_prob * oldp, <END_BUG> vp9_prob * bestp,  vp9_prob upd ) { <START_BUG> int i, old_b, new_b, update_b, savings, bestsavings, step ; int newp ; <END_BUG> vp9_prob bestnewp, newplist [ ENTROPY_NODES ], oldplist [ ENTROPY_NODES ] ;  vp9_model_to_full_probs ( oldp, oldplist ) ; <START_BUG> vpx_memcpy ( newplist, oldp, sizeof ( vp9_prob ) * UNCONSTRAINED_NODES ) ; <END_BUG> for ( i = UNCONSTRAINED_NODES, old_b = 0 ; i < ENTROPY_NODES ; ++ i ) old_b += cost_branch256 ( ct + 2 * i, oldplist [ i ] ) ; old_b += cost_branch256 ( ct + 2 * PIVOT_NODE, oldplist [ PIVOT_NODE ] ) ; bestsavings = 0 ; bestnewp = oldp [ PIVOT_NODE ] ;  step = ( * bestp > oldp [ PIVOT_NODE ]? - 1 : 1 ) ; <START_BUG> for ( newp = * bestp ; newp!= oldp [ PIVOT_NODE ] ; newp += step ) { if ( newp < 1 || newp > 255 ) continue ; newplist [ PIVOT_NODE ] = newp ; vp9_model_to_full_probs ( newplist, newplist ) ; for ( i = UNCONSTRAINED_NODES, new_b = 0 ; i < ENTROPY_NODES ; ++ i ) new_b += cost_branch256 ( ct + 2 * i, newplist [ i ] ) ; new_b += cost_branch256 ( ct + 2 * PIVOT_NODE, newplist [ PIVOT_NODE ] ) ; update_b = prob_diff_update_cost ( newp, oldp [ PIVOT_NODE ] ) + vp9_cost_upd256 ; savings = old_b - new_b - update_b ; if ( savings > bestsavings ) { best<END_BUG>

Fix:
<S2SV_ModStart> ct, const vpx_prob * oldp, vpx_prob <S2SV_ModEnd> * bestp, <S2SV_ModStart> * bestp, vpx_prob upd, int stepsize ) { int <S2SV_ModEnd> i, old_b <S2SV_ModStart> int newp ; vpx_prob <S2SV_ModEnd> bestnewp, newplist <S2SV_ModStart> oldplist ) ; memcpy <S2SV_ModEnd> ( newplist, <S2SV_ModStart>, sizeof ( vpx_prob <S2SV_ModEnd> ) * UNCONSTRAINED_NODES <S2SV_ModStart> PIVOT_NODE ] ; if ( * bestp > oldp [ PIVOT_NODE ] ) { step = - stepsize ; for ( newp = * bestp ; newp > <S2SV_ModEnd> oldp [ PIVOT_NODE <S2SV_ModStart> ; } } } else { step = stepsize ; for ( newp = * bestp ; newp < oldp [ PIVOT_NODE ] ; newp += step ) { if ( newp < 1 || newp > 255 ) continue ; newplist [ PIVOT_NODE ] = newp ; vp9_model_to_full_probs ( newplist, newplist ) ; for ( i = UNCONSTRAINED_NODES, new_b = 0 ; i < ENTROPY_
Buggy code:
 static vpx_codec_err_t vp8_decode ( vpx_codec_alg_priv_t * ctx, const uint8_t * data, unsigned int data_sz, void * user_priv, long deadline ) { vpx_codec_err_t res = VPX_CODEC_OK ; unsigned int resolution_change = 0 ; unsigned int w, h ; if (! ctx -> fragments. enabled && ( data == NULL && data_sz == 0 ) ) { return 0 ; } if ( update_fragments ( ctx, data, data_sz, & res ) <= 0 ) return res ; w = ctx -> si. w ; h = ctx -> si. h ; res = vp8_peek_si_internal ( ctx -> fragments. ptrs [ 0 ], ctx -> fragments. sizes [ 0 ], & ctx -> si, ctx -> decrypt_cb, ctx -> decrypt_state ) ; if ( ( res == VPX_CODEC_UNSUP_BITSTREAM ) &&! ctx -> si. is_kf ) { res = VPX_CODEC_OK ; } if (! ctx -> decoder_init &&! ctx -> si. is_kf ) res = VPX_CODEC_UNSUP_BITSTREAM ; if ( ( ctx -> si. h!= h ) || ( ctx -> si. w!= w ) ) resolution_change = 1 ; if (! res &&! ctx -> decoder_init ) { VP8D_CONFIG oxcf ; oxcf. Width = ctx -> si. w ; oxcf. Height = ctx -> si. h ; oxcf. Version = 9 ; oxcf. postprocess = 0 ; oxcf. max_threads = ctx -> cfg. threads ; oxcf. error_concealment = ( ctx -> base. init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT ) ; if (! ctx -> postproc_cfg_set && ( ctx -> base. init_flags & VPX_CODEC_USE_POSTPROC ) ) { ctx -> postproc_cfg. post_proc_flag = VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE ; ctx -> postproc_cfg. deblocking_level = 4 ; ctx ->

Fix:
<S2SV_ModStart> = 0 ; ctx -> si. w = 0 ; ctx -> si. h = 0 ;
Buggy code:
 <START_BUG> void vp9_loop_filter_frame ( VP9_COMMON * cm, MACROBLOCKD * xd, <END_BUG> int frame_filter_level, int y_only, int partial_frame ) { int start_mi_row, end_mi_row, mi_rows_to_filter ; if (! frame_filter_level ) return ; start_mi_row = 0 ; mi_rows_to_filter = cm -> mi_rows ; if ( partial_frame && cm -> mi_rows > 8 ) { start_mi_row = cm -> mi_rows >> 1 ; start_mi_row &= 0xfffffff8 ; mi_rows_to_filter = MAX ( cm -> mi_rows // 8, 8 ) ; } end_mi_row = start_mi_row + mi_rows_to_filter ; vp9_loop_filter_frame_init ( cm, frame_filter_level ) ;  vp9_loop_filter_rows ( cm -> frame_to_show, cm, xd, <START_BUG> start_mi_row, end_mi_row, y_only ) ; }<END_BUG>

Fix:
<S2SV_ModStart> void vp9_loop_filter_frame ( YV12_BUFFER_CONFIG * frame, <S2SV_ModStart> ; vp9_loop_filter_rows ( frame <S2SV_ModEnd>, cm, <S2SV_ModStart> cm, xd -> plane
Buggy code:
 PyMODINIT_FUNC PyInit__ast3 ( void ) { PyObject * m, * d ; if (! init_types ( ) ) return NULL ; <START_BUG> m = PyModule_Create ( & _astmodule3 ) ; <END_BUG> if (! m ) return NULL ; d = PyModule_GetDict ( m ) ; if ( PyDict_SetItemString ( d, "AST", ( PyObject * ) & AST_type ) < 0 ) return NULL ; if ( PyModule_AddIntMacro ( m, PyCF_ONLY_AST ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "mod", ( PyObject * ) mod_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "Module", ( PyObject * ) Module_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "Interactive", ( PyObject * ) Interactive_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "Expression", ( PyObject * ) Expression_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "FunctionType", ( PyObject * ) FunctionType_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "Suite", ( PyObject * ) Suite_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "stmt", ( PyObject * ) stmt_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "FunctionDef", ( PyObject * ) FunctionDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "AsyncFunctionDef", ( PyObject * ) AsyncFunctionDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "ClassDef", ( PyObject * ) ClassDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "Return", ( PyObject * ) Return_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d, "Delete", ( PyObject * ) Delete_type ) < 0 ) return NULL ; if ( PyDict_SetItemString (

Fix:
<S2SV_ModStart> PyModule_Create ( & _astmodule <S2SV_ModEnd> ) ; if
Buggy code:
 static void doPost ( HttpRequest req, HttpResponse res ) { set_content_type ( res, "text//html" ) ; <START_BUG> if ( ACTION ( RUN ) ) <END_BUG> handle_run ( req, res ) ; else if ( ACTION ( STATUS ) ) print_status ( req, res, 1 ) ; else if ( ACTION ( STATUS2 ) ) print_status ( req, res, 2 ) ; else if ( ACTION ( SUMMARY ) ) print_summary ( req, res ) ; else if ( ACTION ( REPORT ) ) _printReport ( req, res ) ; else if ( ACTION ( DOACTION ) )  handle_do_action ( req, res ) ; <START_BUG> else <END_BUG> handle_action ( req, res ) ;  }

Fix:
<S2SV_ModStart> ( ACTION ( RUNTIME ) ) handle_runtime_action ( req, res ) ; else if ( ACTION ( VIEWLOG ) ) do_viewlog <S2SV_ModEnd> ( req, <S2SV_ModStart> DOACTION ) ) handle_doaction <S2SV_ModEnd> ( req, <S2SV_ModStart> ) ; else handle_service_action <S2SV_ModEnd> ( req,
Buggy code:
 int connection_exit_begin_conn ( cell_t * cell, circuit_t * circ ) { edge_connection_t * n_stream ; relay_header_t rh ; char * address = NULL ; uint16_t port = 0 ; <START_BUG> or_circuit_t * or_circ = NULL ; <END_BUG> const or_options_t * options = get_options ( ) ; begin_cell_t bcell ; int rv ; uint8_t end_reason = 0 ; assert_circuit_ok ( circ ) ;  if (! CIRCUIT_IS_ORIGIN ( circ ) ) <START_BUG> <END_BUG> or_circ = TO_OR_CIRCUIT ( circ ) ;  relay_header_unpack ( & rh, cell -> payload ) ; if ( rh. length > RELAY_PAYLOAD_SIZE ) return - END_CIRC_REASON_TORPROTOCOL ; if (! server_mode ( options ) && circ -> purpose!= CIRCUIT_PURPOSE_S_REND_JOINED ) { log_fn ( LOG_PROTOCOL_WARN, LD_PROTOCOL, "Relay   begin   cell   at   non-server.   Closing." ) ; relay_send_end_cell_from_edge ( rh. stream_id, circ, END_STREAM_REASON_EXITPOLICY, NULL ) ; return 0 ; } rv = begin_cell_parse ( cell, & bcell, & end_reason ) ; if ( rv < - 1 ) { return - END_CIRC_REASON_TORPROTOCOL ; } else if ( rv == - 1 ) { tor_free ( bcell. address ) ; <START_BUG> relay_send_end_cell_from_edge ( rh. stream_id, circ, end_reason, NULL ) ; <END_BUG> return 0 ; } if (! bcell. is_begindir ) { address = bcell. address ; port = bcell. port ; if ( or_circ && or_circ -> p_chan ) { if (! options -> AllowSingleHopExits && ( or_circ -> is_first_hop || (! connection_or_digest_is_known_relay ( or_circ -> p_chan -> identity_digest ) && should_refuse_unknown_exits ( options ) ) ) ) { log_fn

Fix:
<S2SV_ModStart> or_circuit_t * or_circ = NULL ; origin_circuit_t * origin_circ = NULL ; crypt_path_t * layer_hint <S2SV_ModStart> circ ) ) { <S2SV_ModStart> circ ) ; } else { tor_assert ( circ -> purpose == CIRCUIT_PURPOSE_S_REND_JOINED ) ; origin_circ = TO_ORIGIN_CIRCUIT ( circ ) ; layer_hint = origin_circ -> cpath -> prev ; } <S2SV_ModStart>, end_reason, layer_hint <S2SV_ModEnd> ) ; return <S2SV_ModStart>, END_STREAM_REASON_NOTDIRECTORY, layer_hint <S2SV_ModEnd> ) ; return <S2SV_ModStart>, END_STREAM_REASON_INTERNAL, layer_hint <S2SV_ModEnd> ) ; return <S2SV_ModStart>, END_STREAM_REASON_EXITPOLICY, layer_hint <S2SV_ModEnd> ) ; return <S2SV_ModStart> CIRCUIT_PURPOSE_S_REND_JOINED ) { tor_assert ( origin_circ <S2SV_ModEnd> ) ; log_info <S2SV_ModStart>, END_STREAM_REASON_DONE, layer_hint <S2SV_ModEnd> ) ; connection_free
Buggy code:
 static expr_ty ast_for_decorator ( struct compiling * c, const node * n ) { expr_ty d = NULL ; expr_ty name_expr ; REQ ( n, decorator ) ; REQ ( CHILD ( n, 0 ), AT ) ; REQ ( RCHILD ( n, - 1 ), NEWLINE ) ; name_expr = ast_for_dotted_name ( c, CHILD ( n, 1 ) ) ; if (! name_expr ) return NULL ; if ( NCH ( n ) == 3 ) { d = name_expr ; name_expr = NULL ; } else if ( NCH ( n ) == 5 ) { d = Call ( name_expr, NULL, NULL, LINENO ( n ), n -> n_col_offset, c -> c_arena ) ; if (! d ) return NULL ; name_expr = NULL ; } else { <START_BUG> d = ast_for_call ( c, CHILD ( n, 3 ), name_expr ) ; <END_BUG> if (! d ) return NULL ; name_expr = NULL ; } return d ; }

Fix:
<S2SV_ModStart> ), name_expr, true
Buggy code:
 static int store_asoundrc ( void ) { fs_build_mnt_dir ( ) ; char * src ; char * dest = RUN_ASOUNDRC_FILE ; FILE * fp = fopen ( dest, "w" ) ; if ( fp ) { fprintf ( fp, "\\n" ) ; SET_PERMS_STREAM ( fp, getuid ( ), getgid ( ), 0644 ) ; fclose ( fp ) ; } if ( asprintf ( & src, "%s//.asoundrc", cfg. homedir ) == - 1 ) errExit ( "asprintf" ) ; struct stat s ; if ( stat ( src, & s ) == 0 ) { if ( is_link ( src ) ) { char * rp = realpath ( src, NULL ) ; if (! rp ) { fprintf ( stderr, "Error:   Cannot   access   %s\\n", src ) ; exit ( 1 ) ; } if ( strncmp ( rp, cfg. homedir, strlen ( cfg. homedir ) )!= 0 ) { fprintf ( stderr, "Error:  .asoundrc   is   a   symbolic   link   pointing   to   a   file   outside   home   directory\\n" ) ; exit ( 1 ) ; } free ( rp ) ; } <START_BUG> pid_t child = fork ( ) ; <END_BUG> if ( child < 0 ) errExit ( "fork" ) ; if ( child == 0 ) { drop_privs ( 0 ) ; int rv = copy_file ( src, dest, getuid ( ), getgid ( ), 0644 ) ;  if ( rv ) <START_BUG> fprintf ( stderr, "Warning:   cannot   transfer  .asoundrc   in   private   home   directory\\n" ) ; else { <END_BUG> fs_logger2 ( "clone", dest ) ;  } _exit ( 0 ) ; } waitpid ( child, NULL, 0 ) ; return 1 ; } return 0 ; }

Fix:
<S2SV_ModStart> ) ; } copy_file_as_user <S2SV_ModEnd> ( src, <S2SV_ModStart> 0644 ) ; <S2SV_ModEnd> fs_logger2 ( "clone" <S2SV_ModStart> "clone", dest <S2SV_ModEnd> ) ; return
Buggy code:
 MagickExport const char * GetMagickFeatures ( void ) { return "DPC" <START_BUG> # if defined ( MAGICKCORE_BUILD_MODULES ) || defined ( _DLL ) <END_BUG> "   Modules" # endif # if defined ( MAGICKCORE_HDRI_SUPPORT )  "   HDRI" <START_BUG> # endif # if defined ( MAGICKCORE_OPENCL_SUPPORT ) "   OpenCL" # endif # if defined ( MAGICKCORE_OPENMP_SUPPORT ) "   OpenMP" # endif <END_BUG> ;  }

Fix:
<S2SV_ModStart> if defined ( MAGICKCORE_WINDOWS_SUPPORT ) && defined ( _DEBUG ) " <S2SV_blank> Debug" # endif # if defined ( MAGICKCORE_CIPHER_SUPPORT ) " <S2SV_blank> Cipher" <S2SV_ModEnd> # endif # <S2SV_ModStart> MAGICKCORE_HDRI_SUPPORT ) " <S2SV_blank> HDRI" # endif # if defined ( MAGICKCORE_BUILD_MODULES ) || defined ( _DLL ) " <S2SV_blank> Modules" <S2SV_ModStart> " <S2SV_blank> OpenMP" # endif # if defined ( ZERO_CONFIGURATION_SUPPORT ) " <S2SV_blank> Zero-configuration" # endif
Buggy code:
 void vp9_setup_block_planes ( MACROBLOCKD * xd, int ss_x, int ss_y ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) { xd -> plane [ i ]. plane_type = i? PLANE_TYPE_UV : PLANE_TYPE_Y ; xd -> plane [ i ]. subsampling_x = i? ss_x : 0 ; xd -> plane [ i ]. subsampling_y = i? ss_y : 0 ; } <START_BUG> # if CONFIG_ALPHA <END_BUG> xd -> plane [ 3 ]. plane_type = PLANE_TYPE_Y ; xd -> plane [ 3 ]. subsampling_x = 0 ; xd -> plane [ 3 ]. subsampling_y = 0 ; # endif }

Fix:
<S2SV_ModStart> 0 ; } <S2SV_ModEnd> } <S2SV_null> <S2SV_null>
Buggy code:
 static ssize_t driver_override_store ( struct device * dev, struct device_attribute * attr, const char * buf, size_t count ) { struct platform_device * pdev = to_platform_device ( dev ) ; <START_BUG> char * driver_override, * old = pdev -> driver_override, * cp ; <END_BUG> if ( count > PATH_MAX ) return - EINVAL ; driver_override = kstrndup ( buf, count, GFP_KERNEL ) ; if (! driver_override ) return - ENOMEM ; cp = strchr ( driver_override, '\\n' ) ; if ( cp ) * cp = '\\0' ;  if ( strlen ( driver_override ) ) { <START_BUG> pdev -> driver_override = driver_override ; } else { kfree ( driver_override ) ; pdev -> driver_override = NULL ; } <END_BUG> kfree ( old ) ;  return count ; }

Fix:
<S2SV_ModStart>, * old <S2SV_ModEnd>, * cp <S2SV_ModStart> = '\\0' ; device_lock ( dev ) ; old = pdev -> driver_override ; <S2SV_ModStart> NULL ; } device_unlock ( dev ) ;
Buggy code:
 void sqlite3Pragma ( Parse * pParse, Token * pId1, Token * pId2, Token * pValue, int minusFlag ) { char * zLeft = 0 ; char * zRight = 0 ; const char * zDb = 0 ; Token * pId ; char * aFcntl [ 4 ] ; int iDb ; int rc ; sqlite3 * db = pParse -> db ; Db * pDb ; Vdbe * v = sqlite3GetVdbe ( pParse ) ; const PragmaName * pPragma ; if ( v == 0 ) return ; sqlite3VdbeRunOnlyOnce ( v ) ; pParse -> nMem = 2 ; iDb = sqlite3TwoPartName ( pParse, pId1, pId2, & pId ) ; if ( iDb < 0 ) return ; pDb = & db -> aDb [ iDb ] ; if ( iDb == 1 && sqlite3OpenTempDatabase ( pParse ) ) { return ; } zLeft = sqlite3NameFromToken ( db, pId ) ; if (! zLeft ) return ; if ( minusFlag ) { zRight = sqlite3MPrintf ( db, "-%T", pValue ) ; } else { zRight = sqlite3NameFromToken ( db, pValue ) ; } assert ( pId2 ) ; zDb = pId2 -> n > 0? pDb -> zDbSName : 0 ; if ( sqlite3AuthCheck ( pParse, SQLITE_PRAGMA, zLeft, zRight, zDb ) ) { goto pragma_out ; } aFcntl [ 0 ] = 0 ; aFcntl [ 1 ] = zLeft ; aFcntl [ 2 ] = zRight ; aFcntl [ 3 ] = 0 ; db -> busyHandler. nBusy = 0 ; rc = sqlite3_file_control ( db, zDb, SQLITE_FCNTL_PRAGMA, ( void * ) aFcntl ) ; if ( rc == SQLITE_OK ) { sqlite3VdbeSetNumCols ( v, 1 ) ; sqlite3VdbeSetColName ( v, 0, COLNAME_NAME, aFcntl [ 0 ], SQLITE_TRANSIENT ) ; returnSingleText ( v, aFcntl [ 0 ] ) ; sqlite3_free ( aFcnt

Fix:
<S2SV_ModStart> 3 ) ; if ( sqlite3VdbeGetOp ( v, - 1 ) -> opcode == OP_Column ) { <S2SV_ModStart> OPFLAG_TYPEOFARG ) ; }
Buggy code:
 EAS_RESULT DLSParser ( EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE fileHandle, EAS_I32 offset, EAS_DLSLIB_HANDLE * ppDLS ) { EAS_RESULT result ; SDLS_SYNTHESIZER_DATA dls ; EAS_U32 temp ; EAS_I32 pos ; EAS_I32 chunkPos ; EAS_I32 size ; EAS_I32 instSize ; EAS_I32 rgnPoolSize ; EAS_I32 artPoolSize ; EAS_I32 waveLenSize ; EAS_I32 endDLS ; EAS_I32 wvplPos ; EAS_I32 wvplSize ; EAS_I32 linsPos ; EAS_I32 linsSize ; EAS_I32 ptblPos ; EAS_I32 ptblSize ; void * p ; EAS_HWMemSet ( & dls, 0, sizeof ( dls ) ) ; dls. hwInstData = hwInstData ; dls. fileHandle = fileHandle ; * ppDLS = NULL ; if ( ( result = EAS_HWFileSeek ( dls. hwInstData, dls. fileHandle, offset ) )!= EAS_SUCCESS ) return result ; if ( ( result = EAS_HWReadFile ( dls. hwInstData, dls. fileHandle, & temp, sizeof ( temp ), & size ) )!= EAS_SUCCESS ) return result ; dls. bigEndian = ( temp == CHUNK_RIFF ) ; pos = offset ; if ( ( result = NextChunk ( & dls, & pos, & temp, & size ) )!= EAS_SUCCESS ) return result ; if ( temp!= CHUNK_DLS ) { { } return EAS_ERROR_FILE_FORMAT ; } linsSize = wvplSize = ptblSize = linsPos = wvplPos = ptblPos = 0 ; endDLS = offset + size ; pos = offset + 12 ; while ( pos < endDLS ) { chunkPos = pos ; if ( ( result = NextChunk ( & dls, & pos, & temp, & size ) )!= EAS_SUCCESS ) return result ; switch ( temp ) { case CHUNK_CDL : if ( ( result = Parse_

Fix:
<S2SV_ModStart> ) ; } if ( dls. pDLS ) { <S2SV_ModStart> = 1 ; }
Buggy code:
 Datum bit_in ( PG_FUNCTION_ARGS ) { char * input_string = PG_GETARG_CSTRING ( 0 ) ; # ifdef NOT_USED Oid typelem = PG_GETARG_OID ( 1 ) ; # endif int32 atttypmod = PG_GETARG_INT32 ( 2 ) ; VarBit * result ; char * sp ; bits8 * r ; int len, bitlen, slen ; bool bit_not_hex ; int bc ; bits8 x = 0 ; if ( input_string [ 0 ] == 'b' || input_string [ 0 ] == 'B' ) { bit_not_hex = true ; sp = input_string + 1 ; } else if ( input_string [ 0 ] == 'x' || input_string [ 0 ] == 'X' ) { bit_not_hex = false ; sp = input_string + 1 ; } else { bit_not_hex = true ; sp = input_string ; } slen = strlen ( sp ) ; if ( bit_not_hex ) bitlen = slen ; else <START_BUG> bitlen = slen * 4 ; <END_BUG> if ( atttypmod <= 0 ) atttypmod = bitlen ; else if ( bitlen!= atttypmod ) ereport ( ERROR, ( errcode ( ERRCODE_STRING_DATA_LENGTH_MISMATCH ), errmsg ( "bit   string   length   %d   does   not   match   type   bit(%d)", bitlen, atttypmod ) ) ) ; len = VARBITTOTALLEN ( atttypmod ) ; result = ( VarBit * ) palloc0 ( len ) ; SET_VARSIZE ( result, len ) ; VARBITLEN ( result ) = atttypmod ; r = VARBITS ( result ) ; if ( bit_not_hex ) { x = HIGHBIT ; for ( ; * sp ; sp ++ ) { if ( * sp == '1' ) * r |= x ; else if ( * sp!= '0' ) ereport ( ERROR, ( errcode ( ERRCODE_INVALID_TEXT_REPRESENTATION ), errmsg ( "\\"%c\\"   is   not   a   valid   binary   digit", * sp ) ) ) ; x >>= 1 ; if ( x == 0 ) { x = HIGHBIT ; r ++ ; } } } else

Fix:
<S2SV_ModStart> slen ; else { if ( slen > VARBITMAXLEN // 4 ) ereport ( ERROR, ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ), errmsg ( "bit <S2SV_blank> string <S2SV_blank> length <S2SV_blank> exceeds <S2SV_blank> the <S2SV_blank> maximum <S2SV_blank> allowed <S2SV_blank> (%d)", VARBITMAXLEN ) ) ) ; <S2SV_ModStart> * 4 ; }
Buggy code:
 static long ion_ioctl ( struct file * filp, unsigned int cmd, unsigned long arg ) { struct ion_client * client = filp -> private_data ; struct ion_device * dev = client -> dev ; struct ion_handle * cleanup_handle = NULL ; int ret = 0 ; unsigned int dir ; union { struct ion_fd_data fd ; struct ion_allocation_data allocation ; struct ion_handle_data handle ; struct ion_custom_data custom ; } data ; dir = ion_ioctl_dir ( cmd ) ; if ( _IOC_SIZE ( cmd ) > sizeof ( data ) ) return - EINVAL ; if ( dir & _IOC_WRITE ) if ( copy_from_user ( & data, ( void __user * ) arg, _IOC_SIZE ( cmd ) ) ) return - EFAULT ; switch ( cmd ) { case ION_IOC_ALLOC : { struct ion_handle * handle ; handle = ion_alloc ( client, data. allocation. len, data. allocation. align, data. allocation. heap_id_mask, data. allocation. flags ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; data. allocation. handle = handle -> id ; cleanup_handle = handle ; break ; } case ION_IOC_FREE : { struct ion_handle * handle ; <START_BUG> handle = ion_handle_get_by_id ( client, data. handle. handle ) ; <END_BUG>  if ( IS_ERR ( handle ) ) <START_BUG> return PTR_ERR ( handle ) ; <END_BUG> ion_free ( client, handle ) ;  ion_handle_put ( handle ) ; break ; } case ION_IOC_SHARE : case ION_IOC_MAP : { struct ion_handle * handle ; handle = ion_handle_get_by_id ( client, data. handle. handle ) ; if ( IS_ERR ( handle ) ) return PTR_ERR ( handle ) ; data. fd. fd = ion_share_dma_buf_fd ( client, handle ) ; ion_handle_put ( handle ) ; if ( data. fd. fd < 0 ) ret = data. fd. fd ; break ; } case ION_IOC_IMPORT : { struct ion_handle * handle ; handle = ion_import_dma

Fix:
<S2SV_ModStart> * handle ; mutex_lock ( & client -> lock ) ; handle = ion_handle_get_by_id_nolock <S2SV_ModEnd> ( client, <S2SV_ModStart> handle ) ) { mutex_unlock ( & client -> lock ) ; <S2SV_ModStart> handle ) ; } ion_free_nolock ( client, handle ) ; ion_handle_put_nolock ( handle ) ; mutex_unlock ( & client -> lock <S2SV_ModEnd> ) ; break
Buggy code:
 BOOL glyph_cache_put ( rdpGlyphCache * glyphCache, UINT32 id, UINT32 index, rdpGlyph * glyph ) { rdpGlyph * prevGlyph ; if ( id > 9 ) { WLog_ERR ( TAG, "invalid   glyph   cache   id:   %" PRIu32 "", id ) ; return FALSE ; } <START_BUG> if ( index > glyphCache -> glyphCache [ id ]. number ) <END_BUG> { WLog_ERR ( TAG, "invalid   glyph   cache   index:   %" PRIu32 "   in   cache   id:   %" PRIu32 "", index, id ) ; return FALSE ; } WLog_Print ( glyphCache -> log, WLOG_DEBUG, "GlyphCachePut:   id:   %" PRIu32 "   index:   %" PRIu32 "", id, index ) ; prevGlyph = glyphCache -> glyphCache [ id ]. entries [ index ] ; if ( prevGlyph ) prevGlyph -> Free ( glyphCache -> context, prevGlyph ) ; glyphCache -> glyphCache [ id ]. entries [ index ] = glyph ; return TRUE ; }

Fix:
<S2SV_ModStart> if ( index >= <S2SV_ModEnd> glyphCache -> glyphCache
Buggy code:
 static int jp2_bpcc_getdata ( jp2_box_t * box, jas_stream_t * in ) { jp2_bpcc_t * bpcc = & box -> data. bpcc ; <START_BUG> unsigned int i ; <END_BUG> bpcc -> numcmpts = box -> datalen ; if (! ( bpcc -> bpcs = jas_alloc2 ( bpcc -> numcmpts, sizeof ( uint_fast8_t ) ) ) ) { return - 1 ; } for ( i = 0 ; i < bpcc -> numcmpts ; ++ i ) { if ( jp2_getuint8 ( in, & bpcc -> bpcs [ i ] ) ) { return - 1 ; } } return 0 ; }

Fix:
<S2SV_ModStart> unsigned int i ; bpcc -> bpcs = 0
Buggy code:
 static vpx_codec_err_t ctrl_set_reference ( vpx_codec_alg_priv_t * ctx, <START_BUG> int ctr_id, va_list args ) { <END_BUG>  vpx_ref_frame_t * const data = va_arg ( args, vpx_ref_frame_t * ) ; <START_BUG> if ( data ) { vpx_ref_frame_t * const frame = ( vpx_ref_frame_t * ) data ; YV12_BUFFER_CONFIG sd ; <END_BUG> image2yuvconfig ( & frame -> img, & sd ) ;  <START_BUG> return vp9_set_reference_dec ( & ctx -> pbi -> common, <END_BUG> ( VP9_REFFRAME ) frame -> frame_type, & sd ) ; } else { return VPX_CODEC_INVALID_PARAM ; } }

Fix:
<S2SV_ModStart> * ctx, <S2SV_ModEnd> va_list args ) <S2SV_ModStart> * ) ; if ( ctx -> frame_parallel_decode ) { set_error_detail ( ctx, "Not <S2SV_blank> supported <S2SV_blank> in <S2SV_blank> frame <S2SV_blank> parallel <S2SV_blank> decode" ) ; return VPX_CODEC_INCAPABLE ; } <S2SV_ModStart> YV12_BUFFER_CONFIG sd ; VPxWorker * const worker = ctx -> frame_workers ; FrameWorkerData * const frame_worker_data = ( FrameWorkerData * ) worker -> data1 ; <S2SV_ModStart> vp9_set_reference_dec ( & frame_worker_data <S2SV_ModEnd> -> pbi ->
Buggy code:
 int jpg_validate ( jas_stream_t * in ) { <START_BUG> uchar buf [ JPG_MAGICLEN ] ; <END_BUG> int i ; int n ; assert ( JAS_STREAM_MAXPUTBACK >= JPG_MAGICLEN ) ; if ( ( n = jas_stream_read ( in, buf, JPG_MAGICLEN ) ) < 0 ) { return - 1 ; } for ( i = n - 1 ; i >= 0 ; -- i ) { if ( jas_stream_ungetc ( in, buf [ i ] ) == EOF ) { return - 1 ; } } if ( n < JPG_MAGICLEN ) { return - 1 ; } if ( buf [ 0 ]!= ( JPG_MAGIC >> 8 ) || buf [ 1 ]!= ( JPG_MAGIC & 0xff ) ) { return - 1 ; } return 0 ; }

Fix:
<S2SV_ModStart> in ) { jas_uchar <S2SV_ModEnd> buf [ JPG_MAGICLEN
Buggy code:
 static void pci_bus_write_dsdt ( int bus ) { struct businfo * bi ; struct slotinfo * si ; struct pci_vdev * dev ; int count, func, slot ; bi = pci_businfo [ bus ] ; if ( bi == NULL ) { if ( bus!= 0 ) return ; } dsdt_line ( "     Device   (PCI%01X)", bus ) ; dsdt_line ( "     {" ) ; dsdt_line ( "         Name   (_HID,   EisaId   (\\"PNP0A03\\"))" ) ; dsdt_line ( "         Name   (_ADR,   Zero)" ) ; dsdt_line ( "         Method   (_BBN,   0,   NotSerialized)" ) ; dsdt_line ( "         {" ) ; dsdt_line ( "                 Return   (0x%08X)", bus ) ; dsdt_line ( "         }" ) ; dsdt_line ( "         Name   (_CRS,   ResourceTemplate   ()" ) ; dsdt_line ( "         {" ) ; dsdt_line ( "             WordBusNumber   (ResourceProducer,   MinFixed,   " "MaxFixed,   PosDecode," ) ; dsdt_line ( "                 0x0000,                           ////   Granularity" ) ; dsdt_line ( "                 0x%04X,                           ////   Range   Minimum", bus ) ; dsdt_line ( "                 0x%04X,                           ////   Range   Maximum", bus ) ; dsdt_line ( "                 0x0000,                           ////   Translation   Offset" ) ; dsdt_line ( "                 0x0001,                           ////   Length

Fix:
<S2SV_ModStart> ; } } <S2SV_ModEnd> dsdt_line ( " <S2SV_blank> <S2SV_blank> <S2SV_blank> <S2SV_blank> <S2SV_blank> <S2SV_blank> WordIO <S2SV_blank> (ResourceProducer, <S2SV_blank> MinFixed, <S2SV_blank> MaxFixed, <S2SV_blank> "
Buggy code:
 static void change_port_settings ( struct tty_struct * tty, struct edgeport_port * edge_port, struct ktermios * old_termios ) { struct device * dev = & edge_port -> port -> dev ; struct ump_uart_config * config ; int baud ; unsigned cflag ; int status ; int port_number = edge_port -> port -> port_number ; config = kmalloc ( sizeof ( * config ), GFP_KERNEL ) ; if (! config ) { tty -> termios = * old_termios ; return ; } cflag = tty -> termios. c_cflag ; config -> wFlags = 0 ; config -> wFlags |= UMP_MASK_UART_FLAGS_RECEIVE_MS_INT ; config -> wFlags |= UMP_MASK_UART_FLAGS_AUTO_START_ON_ERR ; config -> bUartMode = ( __u8 ) ( edge_port -> bUartMode ) ; switch ( cflag & CSIZE ) { case CS5 : config -> bDataBits = UMP_UART_CHAR5BITS ; dev_dbg ( dev, "%s   -   data   bits   =   5\\n", __func__ ) ; break ; case CS6 : config -> bDataBits = UMP_UART_CHAR6BITS ; dev_dbg ( dev, "%s   -   data   bits   =   6\\n", __func__ ) ; break ; case CS7 : config -> bDataBits = UMP_UART_CHAR7BITS ; dev_dbg ( dev, "%s   -   data   bits   =   7\\n", __func__ ) ; break ; default : case CS8 : config -> bDataBits = UMP_UART_CHAR8BITS ; dev_dbg ( dev, "%s   -   data   bits   =   8\\n", __func__ ) ; break ; } if ( cflag & PARENB ) { if ( cflag & PARODD ) { config -> wFlags |= UMP_MASK_UART_FLAGS_PARITY ; config -> bParity = UMP_UART_ODDPARITY ; dev_dbg ( dev, "%s   -   parity   =   odd\\n", __func

Fix:
<S2SV_ModStart> ; } else { baud = min ( baud, 461550 ) ; <S2SV_ModStart> baud ) ; }
Buggy code:
 int btrfs_scrub_progress ( struct btrfs_fs_info * fs_info, u64 devid, struct btrfs_scrub_progress * progress ) { struct btrfs_device * dev ; struct scrub_ctx * sctx = NULL ; mutex_lock ( & fs_info -> fs_devices -> device_list_mutex ) ; <START_BUG> dev = btrfs_find_device ( fs_info -> fs_devices, devid, NULL, NULL ) ; <END_BUG> if ( dev ) sctx = dev -> scrub_ctx ; if ( sctx ) memcpy ( progress, & sctx -> stat, sizeof ( * progress ) ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; return dev? ( sctx? 0 : - ENOTCONN ) : - ENODEV ; }

Fix:
<S2SV_ModStart> NULL, NULL, true
Buggy code:
 unsigned long lh_char_hash ( const void * k ) { <START_BUG> unsigned int h = 0 ; <END_BUG>  const char * data = ( const char * ) k ; <START_BUG> while ( * data!= 0 ) h = h * 129 + ( unsigned int ) ( * data ++ ) + LH_PRIME ; return h ; }<END_BUG>

Fix:
<S2SV_ModStart> k ) { static volatile int random_seed = - 1 ; if ( random_seed == - 1 ) { int seed ; while ( ( seed = json_c_get_random_seed ( ) ) == - 1 ) ; # if defined __GNUC__ __sync_val_compare_and_swap ( & random_seed, - 1, seed ) ; # elif defined _MSC_VER InterlockedCompareExchange ( & random_seed, seed, - 1 ) ; # else # warning "racy <S2SV_blank> random <S2SV_blank> seed <S2SV_blank> initializtion <S2SV_blank> if <S2SV_blank> used <S2SV_blank> by <S2SV_blank> multiple <S2SV_blank> threads" random_seed = seed ; # endif } return hashlittle ( <S2SV_ModEnd> ( const char <S2SV_ModStart> * ) k, strlen ( ( const char * ) k ), random_seed ) <S2SV_ModEnd> ; } <S2SV_null>