input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Override public Object handle(HttpExchange x) throws Exception { int event = U.num(x.data("event")); TagContext ctx = Pages.ctx(x); Map<Integer, Object> inp = Pages.inputs(x); ctx.emit(inp, event); Object page = U.newInstance(currentPage(x)); ctx = Tags....
#fixed code @Override public Object handle(HttpExchange x) throws Exception { return Pages.emit(x); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object getParamValue(Req req, Class<?> paramType, String paramName, Map<String, Object> properties) throws Exception { return req.custom().jackson().convertValue(properties, paramType); } #location 3 ...
#fixed code @Override public Object getParamValue(Req req, Class<?> paramType, String paramName, Map<String, Object> properties) throws Exception { return Customization.of(req).jackson().convertValue(properties, paramType); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equ...
#fixed code @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ScanParams that = (ScanParams) o; if (!Arrays.equals(packages, that.packages)) return false; if (matching != null ? !matching.equals(th...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public static WebApp bootstrap(WebApp app, String[] args, Object... config) { Log.info("Starting Rapidoid...", "version", RapidoidInfo.version()); ConfigHelp.processHelp(args); // FIXME make optional // print internal state // Lo...
#fixed code @SuppressWarnings("unchecked") public static WebApp bootstrap(WebApp app, String[] args, Object... config) { Log.info("Starting Rapidoid...", "version", RapidoidInfo.version()); ConfigHelp.processHelp(args); // FIXME make optional // print internal state // LoggerCo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean handleError(Channel channel, boolean isKeepAlive, ReqImpl req, MediaType contentType, Throwable e) { if (req != null) { if (!req.isStopped()) { HttpIO.errorAndDone(req, e, customization.errorHandler()); } return true; } else { Log.error...
#fixed code private boolean handleError(Channel channel, boolean isKeepAlive, ReqImpl req, MediaType contentType, Throwable e) { if (req != null) { if (!req.isStopped()) { HttpIO.errorAndDone(req, e); } return true; } else { Log.error("Low-level HTTP handler error!", e)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); ...
#fixed code @Override public void reset() { super.reset(); isGet.value = false; isKeepAlive.value = false; verb.reset(); uri.reset(); path.reset(); query.reset(); protocol.reset(); body.reset(); multipartBoundary.reset(); params.reset(); headersKV.reset(); head...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void setRootPath(String rootPath) { Log.info("Setting 'root' application path", "path", rootPath); Conf.rootPath = cleanPath(rootPath); setStaticPath(Conf.rootPath + "/static"); setDynamicPath(Conf.rootPath + "/dynamic"); setConfigPath(Conf.rootPath...
#fixed code public static void setRootPath(String rootPath) { Log.info("Setting 'root' application path", "path", rootPath); Conf.rootPath = cleanPath(rootPath); setStaticPath(Conf.rootPath + "/static"); setDynamicPath(Conf.rootPath + "/dynamic"); setConfigPath(Conf.rootPath); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static List<Class<?>> getClassesFromJAR(String jarName, List<Class<?>> classes, String pkg, Pattern regex, Predicate<Class<?>> filter, Class<? extends Annotation> annotated, ClassLoader classLoader) { try { String pkgPath = pkgToPath(pkg); ZipInputStrea...
#fixed code private static List<Class<?>> getClassesFromJAR(String jarName, List<Class<?>> classes, String pkg, Pattern regex, Predicate<Class<?>> filter, Class<? extends Annotation> annotated, ClassLoader classLoader) { ZipInputStream zip = null; try { String pkgPath = pkgToPath...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static DivTag field(FormLayout layout, String name, String desc, FieldType type, Object[] options, Object value) { desc = U.or(desc, name); String inputId = "_" + name; // FIXME Object inp = input_(inputId, name, desc, type, options, value); LabelTag la...
#fixed code public static DivTag field(FormLayout layout, String name, String desc, FieldType type, Object[] options, Object value) { desc = U.or(desc, name); String inputId = "_" + name; // FIXME Object inp = input_(inputId, name, desc, type, options, value); LabelTag label; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String loadResourceAsString(String filename) { return new String(loadBytes(filename)); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public static String loadResourceAsString(String filename) { byte[] bytes = loadBytes(filename); return bytes != null ? new String(bytes) : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static char[] readPassword(String msg) { Console console = System.console(); if (console != null) { return console.readPassword(msg); } else { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); U.print(msg); try { ...
#fixed code private static char[] readPassword(String msg) { Console console = System.console(); if (console != null) { return console.readPassword(msg); } else { U.print(msg); return readLine().toCharArray(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEncryptWithCustomPassword() { byte[] key = Crypto.pbkdf2("pass".toCharArray()); for (int i = 0; i < 10000; i++) { String msg1 = "" + i; byte[] enc = Crypto.encrypt(msg1.getBytes(), key); byte[] dec = Crypto.decrypt(enc, key); Strin...
#fixed code @Test public void testEncryptWithCustomPassword() { CryptoKey key = CryptoKey.from("pass".toCharArray()); for (int i = 0; i < 10000; i++) { String msg1 = "" + i; byte[] enc = Crypto.encrypt(msg1.getBytes(), key); byte[] dec = Crypto.decrypt(enc, key); String ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() :...
#fixed code @Override public int hashCode() { int result = Arrays.hashCode(packages); result = 31 * result + (matching != null ? matching.hashCode() : 0); result = 31 * result + Arrays.hashCode(annotated); result = 31 * result + (classLoader != null ? classLoader.hashCode() : 0); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout = 30000) public void testJDBCPoolC3P0() { JDBC.h2("test1").pooled(); C3P0ConnectionPool pool = (C3P0ConnectionPool) JDBC.defaultApi().pool(); ComboPooledDataSource c3p0 = pool.pool(); // validate default config eq(c3p0.getMinPoolSize(), 5); eq...
#fixed code @Test(timeout = 30000) public void testJDBCPoolC3P0() { JDBC.h2("test1"); C3P0ConnectionPool pool = (C3P0ConnectionPool) JDBC.defaultApi().init().pool(); ComboPooledDataSource c3p0 = pool.pool(); // validate default config eq(c3p0.getMinPoolSize(), 5); eq(c3p0.ge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private byte[] responseToBytes() { try { return response.renderToBytes(); } catch (Throwable e) { HttpIO.error(this, e, custom().errorHandler()); try { return response.renderToBytes(); } catch (Exception e1) { Log.error("Internal rendering error!...
#fixed code private byte[] responseToBytes() { try { return response.renderToBytes(); } catch (Throwable e) { HttpIO.error(this, e, Customization.of(this).errorHandler()); try { return response.renderToBytes(); } catch (Exception e1) { Log.error("Internal renderin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { final HttpParser parser = new HttpParser(); final Buf[] reqs = {r(REQ1), r(REQ2), r(REQ3), r(REQ4)}; final RapidoidHelper helper = new RapidoidHelper(null); BufRange[] ranges = helper.ranges1.ranges; final BufRanges head...
#fixed code public static void main(String[] args) { final HttpParser parser = new HttpParser(); final Buf[] reqs = {r(REQ1), r(REQ2), r(REQ3), r(REQ4)}; final RapidoidHelper helper = new RapidoidHelper(null); for (int i = 0; i < 100; i++) { Msc.benchmark("parse", 3000000, new ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void render(Req req, Object value, OutputStream out) throws Exception { Customization.of(req).jackson().writeValue(out, value); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public void render(Req req, Object value, OutputStream out) throws Exception { Customization.of(req).objectMapper().writeValue(out, value); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void getClassesFromDir(Collection<Class<?>> classes, File root, File dir, String pkg, Pattern regex, Predicate<Class<?>> filter, Class<? extends Annotation> annotated, ClassLoader classLoader) { U.must(dir.isDirectory()); Log.debug("Traversing directo...
#fixed code private static void getClassesFromDir(Collection<Class<?>> classes, File root, File dir, String pkg, Pattern regex, Predicate<Class<?>> filter, Class<? extends Annotation> annotated, ClassLoader classLoader) { U.must(dir.isDirectory()); Log.debug("Traversing directory", "...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Future<byte[]> post(String uri, Map<String, String> headers, Map<String, String> data, Map<String, String> files, Callback<byte[]> callback) { headers = U.safe(headers); data = U.safe(data); files = U.safe(files); HttpPost req = new HttpPost(uri); Mu...
#fixed code public Future<byte[]> post(String uri, Map<String, String> headers, Map<String, String> data, Map<String, String> files, Callback<byte[]> callback) { return request("POST", uri, headers, data, files, null, null, callback); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void completeResponse() { long wrote = output().size() - bodyPos; U.must(wrote <= Integer.MAX_VALUE, "Response too big!"); int pos = startingPos + getResp(responseCode).contentLengthPos + 10; output().putNumAsText(pos, wrote, false); } ...
#fixed code public void completeResponse() { U.must(responseCode >= 100); long wrote = output().size() - bodyPos; U.must(wrote <= Integer.MAX_VALUE, "Response too big!"); int pos = startingPos + getResp(responseCode).contentLengthPos + 10; output().putNumAsText(pos, wrote, false)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected byte[] loadRes(String filename) { try { URL res = resource(filename); return res != null ? readBytes(new FileInputStream(new File(res.getFile()))) : null; } catch (FileNotFoundException e) { throw new RuntimeException(e); } } ...
#fixed code protected byte[] loadRes(String filename) { InputStream input = TestCommons.class.getClassLoader().getResourceAsStream(filename); return input != null ? readBytes(input) : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] render(ReqImpl req, Resp resp) { Object result = resp.result(); if (result != null) { result = wrapGuiContent(result); resp.model().put("result", result); resp.result(result); } ViewRenderer viewRenderer = req.routes().custom().view...
#fixed code public static byte[] render(ReqImpl req, Resp resp) { Object result = resp.result(); if (result != null) { result = wrapGuiContent(result); resp.model().put("result", result); resp.result(result); } ViewRenderer viewRenderer = Customization.of(req).viewRender...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initDbConnectServer() throws Exception{ dbRpcConnnectManngeer.initManager(); dbRpcConnnectManngeer.initServers(sdDbServers); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATI...
#fixed code public void initDbConnectServer() throws Exception{ dbRpcConnnectManngeer.initManager(); dbRpcConnnectManngeer.initServers(rpcConfig.getSdDbServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initDbConnectServer() throws Exception{ worldRpcConnectManager.initManager(); dbRpcConnnectManngeer.initServers(sdDbServers); } #location 2 #vulnerability type THREAD_SAFETY_VIOLAT...
#fixed code public void initDbConnectServer() throws Exception{ dbRpcConnnectManngeer.initManager(); dbRpcConnnectManngeer.initServers(sdDbServers); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initWorldConnectedServer() throws Exception { worldRpcConnectManager.initManager(); worldRpcConnectManager.initServers(sdWorldServers); } #location 3 #vulnerability type THREAD_SAF...
#fixed code public void initWorldConnectedServer() throws Exception { worldRpcConnectManager.initManager(); worldRpcConnectManager.initServers(rpcConfig.getSdWorldServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception{ final String data = "博主邮箱:zou90512@126.com"; byte[] bytes = data.getBytes(Charset.forName("UTF-8")); InetSocketAddress targetHost = new InetSocketAddress("127.0.0.1", 9999); // 发送...
#fixed code public static void main(String[] args) throws Exception{ final String data = "博主邮箱:zou90512@126.com"; byte[] bytes = data.getBytes(Charset.forName("UTF-8")); InetSocketAddress targetHost = new InetSocketAddress("127.0.0.1", 9999); // 发送udp内容 ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initDbConnectServer() throws Exception{ dbRpcConnnectManngeer.initManager(); dbRpcConnnectManngeer.initServers(sdDbServers); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATI...
#fixed code public void initDbConnectServer() throws Exception{ dbRpcConnnectManngeer.initManager(); dbRpcConnnectManngeer.initServers(rpcConfig.getSdDbServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initWorldConnectedServer() throws Exception { worldRpcConnectManager.initManager(); worldRpcConnectManager.initServers(sdWorldServers); } #location 2 #vulnerability type THREAD_SAF...
#fixed code public void initWorldConnectedServer() throws Exception { worldRpcConnectManager.initManager(); worldRpcConnectManager.initServers(rpcConfig.getSdWorldServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initDbConnectServer() throws Exception{ dbRpcConnnectManngeer.initManager(); dbRpcConnnectManngeer.initServers(sdDbServers); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATI...
#fixed code public void initDbConnectServer() throws Exception{ dbRpcConnnectManngeer.initManager(); dbRpcConnnectManngeer.initServers(rpcConfig.getSdDbServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public void init() throws Exception { Element rootElement = JdomUtils.getRootElemet(FileUtil.getConfigURL(GlobalConstants.ConfigFile.RPC_SERVER_CONFIG).getFile()); Map<Integer, SdServer> serverMap = new HashMap<>(); ...
#fixed code @SuppressWarnings("unchecked") public void init() throws Exception { initWorldConnectedServer(); initGameConnectedServer(); initDbConnectServer(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void loadPackage(String namespace, String ext) throws Exception { if(fileNames == null){ fileNames = messageScanner.scannerPackage(namespace, ext); } // 加载class,获取协议命令 DefaultClassLoader defaultClassLoader =...
#fixed code public void loadPackage(String namespace, String ext) throws Exception { if(fileNames == null){ fileNames = messageScanner.scannerPackage(namespace, ext); } // 加载class,获取协议命令 DefaultClassLoader defaultClassLoader = Local...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initGameConnectedServer() throws Exception { gameRpcConnecetMananger.initManager(); gameRpcConnecetMananger.initServers(sdGameServers); } #location 2 #vulnerability type THREAD_SAF...
#fixed code public void initGameConnectedServer() throws Exception { gameRpcConnecetMananger.initManager(); gameRpcConnecetMananger.initServers(rpcConfig.getSdGameServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public void init() throws Exception { Element rootElement = JdomUtils.getRootElemet(FileUtil.getConfigURL(GlobalConstants.ConfigFile.RPC_SERVER_CONFIG).getFile()); Map<Integer, SdServer> serverMap = new HashMap<>(); ...
#fixed code @SuppressWarnings("unchecked") public void init() throws Exception { initWorldConnectedServer(); initGameConnectedServer(); initDbConnectServer(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void loadPackage(String namespace, String ext) throws Exception { if(fileNames == null){ fileNames = messageScanner.scannerPackage(namespace, ext); } // 加载class,获取协议命令 DefaultClassLoader defaultClassLoader =...
#fixed code public void loadPackage(String namespace, String ext) throws Exception { if(fileNames == null){ fileNames = messageScanner.scannerPackage(namespace, ext); } // 加载class,获取协议命令 DefaultClassLoader defaultClassLoader = Local...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initGameConnectedServer() throws Exception { gameRpcConnecetMananger.initManager(); gameRpcConnecetMananger.initServers(sdGameServers); } #location 3 #vulnerability type THREAD_SAF...
#fixed code public void initGameConnectedServer() throws Exception { gameRpcConnecetMananger.initManager(); gameRpcConnecetMananger.initServers(rpcConfig.getSdGameServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initWorldConnectedServer() throws Exception { worldRpcConnectManager.initManager(); worldRpcConnectManager.initServers(sdWorldServers); } #location 3 #vulnerability type THREAD_SAF...
#fixed code public void initWorldConnectedServer() throws Exception { worldRpcConnectManager.initManager(); worldRpcConnectManager.initServers(rpcConfig.getSdWorldServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public void init() throws Exception { Element rootElement = JdomUtils.getRootElemet(FileUtil.getConfigURL(GlobalConstants.ConfigFile.RPC_SERVER_CONFIG).getFile()); Map<Integer, SdServer> serverMap = new HashMap<>(); ...
#fixed code @SuppressWarnings("unchecked") public void init() throws Exception { initWorldConnectedServer(); initGameConnectedServer(); initDbConnectServer(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initGameConnectedServer() throws Exception { gameRpcConnecetMananger.initManager(); gameRpcConnecetMananger.initServers(sdGameServers); } #location 3 #vulnerability type THREAD_SAF...
#fixed code public void initGameConnectedServer() throws Exception { gameRpcConnecetMananger.initManager(); gameRpcConnecetMananger.initServers(rpcConfig.getSdGameServers()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initGameConnectedServer() throws Exception { worldRpcConnectManager.initManager(); gameRpcConnecetMananger.initServers(sdGameServers); } #location 2 #vulnerability type THREAD_SAFE...
#fixed code public void initGameConnectedServer() throws Exception { gameRpcConnecetMananger.initManager(); gameRpcConnecetMananger.initServers(sdGameServers); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code Object fromDb(DBObject dbObject, final Object entity, EntityCache cache) { // check the history key (a key is the namespace + id) if (dbObject.containsField(ID_KEY) && getMappedClass(entity).getIdField() != null && getMappedClass(entity).getEntityAnnotation() !=...
#fixed code Object fromDb(DBObject dbObject, final Object entity, EntityCache cache) { // check the history key (a key is the namespace + id) if (dbObject.containsField(ID_KEY) && getMappedClass(entity).getIdField() != null && getMappedClass(entity).getEntityAnnotation() != null)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Object getId(Object entity) { entity = ProxyHelper.unwrap(entity); MappedClass mc; String keyClassName = entity.getClass().getName(); if (mapr.getMappedClasses().containsKey(keyClassName)) mc = mapr.getMappedClasses().get(keyClassName); else mc = ...
#fixed code protected Object getId(Object entity) { entity = ProxyHelper.unwrap(entity); // String keyClassName = entity.getClass().getName(); MappedClass mc = mapr.getMappedClass(entity.getClass()); // // if (mapr.getMappedClasses().containsKey(keyClassName)) // mc = mapr.getMapp...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> Key<T> save(String kind, T entity) { entity = ProxyHelper.unwrap(entity); DBCollection dbColl = getDB().getCollection(kind); return save(dbColl, entity, defConcern); } #location 4 #vulnerability ty...
#fixed code public <T> Key<T> save(String kind, T entity) { entity = ProxyHelper.unwrap(entity); DBCollection dbColl = getDB().getCollection(kind); return save(dbColl, entity, getWriteConcern(entity)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private <T> Iterable<Key<T>> insert(final DBCollection dbColl, final Iterable<T> entities, final WriteConcern wc) { final List<DBObject> list = entities instanceof List ? new ArrayList<DBObject>(((List<T>) entities).size()) ...
#fixed code private <T> Iterable<Key<T>> insert(final DBCollection dbColl, final Iterable<T> entities, final WriteConcern wc) { // return save(entities, wc); final List<DBObject> list = entities instanceof List ? new ArrayList<DB...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code Object fromDb(DBObject dbObject, final Object entity, EntityCache cache) { // check the history key (a key is the namespace + id) if (dbObject.containsField(ID_KEY) && getMappedClass(entity).getIdField() != null && getMappedClass(entity).getEntityAnnotation() !=...
#fixed code Object fromDb(DBObject dbObject, final Object entity, EntityCache cache) { //hack to bypass things and just read the value. if (entity instanceof MappedField) { readMappedField(dbObject, (MappedField) entity, entity, cache); return entity; } // check the history...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object toMongoObject(final MappedField mf, final MappedClass mc, final Object value) { Object mappedValue = value; //convert the value to Key (DBRef) if the field is @Reference or type is Key/DBRef, or if the destination class is an @Entity ...
#fixed code public Object toMongoObject(final MappedField mf, final MappedClass mc, final Object value) { Object mappedValue = value; //convert the value to Key (DBRef) if the field is @Reference or type is Key/DBRef, or if the destination class is an @Entity if ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> UpdateResults<T> update(T ent, UpdateOperations<T> ops) { MappedClass mc = mapr.getMappedClass(ent); Query<T> q = (Query<T>) createQuery(mc.getClazz()); q.disableValidation().filter(Mapper.ID_KEY, getId(ent)); if (mc.getFieldsAnnotatedWith(Version.cla...
#fixed code public <T> UpdateResults<T> update(T ent, UpdateOperations<T> ops) { if (ent instanceof Query) return update((Query<T>)ent, ops); MappedClass mc = mapr.getMappedClass(ent); Query<T> q = (Query<T>) createQuery(mc.getClazz()); q.disableValidation().filter(Mapper.ID_K...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Key<?> exists(final Object entityOrKey) { final Object unwrapped = ProxyHelper.unwrap(entityOrKey); final Key<?> key = mapper.getKey(unwrapped); final Object id = key.getId(); if (id == null) { throw new MappingException("Could not get id for ...
#fixed code public Key<?> exists(final Object entityOrKey) { final Query<?> query = buildExistsQuery(entityOrKey); return query.getKey(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> Iterable<Key<T>> insert(Iterable<T> entities, WriteConcern wc) { ArrayList<DBObject> ents = entities instanceof List ? new ArrayList<DBObject>(((List<T>)entities).size()) : new ArrayList<DBObject>(); Map<Object, DBObject> involvedObjects = new LinkedHashMap...
#fixed code public <T> Iterable<Key<T>> insert(Iterable<T> entities, WriteConcern wc) { //TODO: Do this without creating another iterator DBCollection dbColl = getCollection(entities.iterator().next()); return insert(dbColl, entities, wc); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String getCollectionName(Object object) { MappedClass mc = getMappedClass(object); return mc.getCollectionName(); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code public String getCollectionName(Object object) { if (object == null) throw new IllegalArgumentException(); MappedClass mc = getMappedClass(object); return mc.getCollectionName(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void updateKeyInfo(final Object entity, final DBObject dbObj, EntityCache cache) { MappedClass mc = getMappedClass(entity); // update id field, if there. if ((mc.getIdField() != null) && (dbObj != null) && (dbObj.get(ID_KEY) != null)) { try { MappedF...
#fixed code public void updateKeyInfo(final Object entity, final DBObject dbObj, EntityCache cache) { MappedClass mc = getMappedClass(entity); // update id field, if there. if ((mc.getIdField() != null) && (dbObj != null) && (dbObj.get(ID_KEY) != null)) { try { MappedField m...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void execute() { if (help) { command.usage("init"); } else { try { URL searchURL = new URL(MVN_SEARCH_URL); InputStream is = null; Map<String, String> pluginsList = new LinkedHashMap<String, String>(); Map<String, String> pluginsURLs = new ...
#fixed code public void execute() { if (help) { command.usage("init"); } else { try { URL searchURL = new URL(MVN_SEARCH_URL); InputStream is = null; Map<String, String> pluginsList = new LinkedHashMap<String, String>(); Map<String, String> pluginsURLs = new Linked...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void execute() { if (help) { command.usage("init"); } else { try { WalkModFacade facade = new WalkModFacade(OptionsBuilder.options()); Configuration cfg = facade.getConfiguration(); Collection<PluginConfig> installedPlugins = cfg.getPlugins(); ...
#fixed code public void execute() { if (help) { command.usage("init"); } else { try { WalkModFacade facade = new WalkModFacade(OptionsBuilder.options()); Configuration cfg = facade.getConfiguration(); Collection<PluginConfig> installedPlugins = null; if(cfg !=...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void load() throws ConfigurationException { Collection<PluginConfig> plugins = configuration.getPlugins(); PluginConfig plugin = null; Collection<File> jarsToLoad = new LinkedList<File>(); try { if (plugins != null) { Iterator<PluginConfig>...
#fixed code @Override public void load() throws ConfigurationException { Collection<PluginConfig> plugins = configuration.getPlugins(); PluginConfig plugin = null; Collection<File> jarsToLoad = new LinkedList<File>(); ConfigurationException ce = null; try { if (plugins != null...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void execute() { if (help) { command.usage("init"); } else { try { URL searchURL = new URL(MVN_SEARCH_URL); InputStream is = null; Map<String, String> pluginsList = new LinkedHashMap<String, String>(); Map<String, String> pluginsURLs = new ...
#fixed code public void execute() { if (help) { command.usage("init"); } else { try { URL searchURL = new URL(MVN_SEARCH_URL); InputStream is = null; Map<String, String> pluginsList = new LinkedHashMap<String, String>(); Map<String, String> pluginsURLs = new Linked...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void write(Object n, VisitorContext vc) throws Exception { File out = null; boolean createdEmptyFile = false; if (vc != null) { out = (File) vc.get(AbstractWalker.ORIGINAL_FILE_KEY); } if (out == null) { log.debug("Creating the target source file. T...
#fixed code public void write(Object n, VisitorContext vc) throws Exception { File out = null; boolean createdEmptyFile = false; if (vc != null) { out = (File) vc.get(AbstractWalker.ORIGINAL_FILE_KEY); } if (out == null) { log.debug("Creating the target source file. This is...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static List<File> findFiles(final File parent, boolean recurse) { final List<File> result = new ArrayList<File>(); if (parent.isDirectory()) { File[] files = parent.listFiles(); for (File child : files) { i...
#fixed code private static List<File> findFiles(final File parent, boolean recurse) { final List<File> result = new ArrayList<File>(); if (parent.isDirectory()) { File[] files = parent.listFiles(); files = (files != null ? files : new File[0]); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Object parseIterable(final StartElement iterableEvent, final SerIterable iterable) throws Exception { Attribute rowsAttr = iterableEvent.getAttributeByName(ROWS_QNAME); Attribute columnsAttr = iterableEvent.getAttributeByName(COLS_QNAME); ...
#fixed code private Object parseIterable(final StartElement iterableEvent, final SerIterable iterable) throws Exception { Attribute rowsAttr = iterableEvent.getAttributeByName(ROWS_QNAME); Attribute columnsAttr = iterableEvent.getAttributeByName(COLS_QNAME); if (r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static BeanCodeGen createFromArgs(String[] args) { if (args == null) { throw new IllegalArgumentException("Arguments must not be null"); } String indent = " "; String prefix = ""; boolean recurse = false; ...
#fixed code public static BeanCodeGen createFromArgs(String[] args) { if (args == null) { throw new IllegalArgumentException("Arguments must not be null"); } String indent = " "; String prefix = ""; boolean recurse = false; i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void writeElements(final String currentIndent, final SerIterator itemIterator) { // find converter once for performance, and before checking if key is bean StringConverter<Object> keyConverter = null; StringConverter<Object> rowConverter ...
#fixed code private void writeElements(final String currentIndent, final SerIterator itemIterator) { // find converter once for performance, and before checking if key is bean StringConverter<Object> keyConverter = null; StringConverter<Object> rowConverter = null...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); InputStream i...
#fixed code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R27_SR1_global.txt"); gcResource.getLogger().addHandler(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public DataReader getDataReader(InputStream inStream) throws IOException { BufferedInputStream in = new BufferedInputStream(inStream, FOUR_KB); in.mark(FOUR_KB); byte[] buf = new byte[ONE_KB * 3]; int length = in.read(buf); in.res...
#fixed code public DataReader getDataReader(InputStream inStream) throws IOException { BufferedInputStream in = new BufferedInputStream(inStream, FOUR_KB); DataReader dataReader = null; long nextPos = 0; String chunkOfLastLine = null; int attemptCo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void setTotalAndPreUsed(GCEvent event, StartElement startEl) { long total = NumberParser.parseInt(getAttributeValue(startEl, "total")); event.setTotal(toKiloBytes(total)); event.setPreUsed(toKiloBytes(total - NumberParser.parseInt(getAttr...
#fixed code private void setTotalAndPreUsed(GCEvent event, StartElement startEl) { long total = NumberParser.parseLong(getAttributeValue(startEl, "total")); event.setTotal(toKiloBytes(total)); event.setPreUsed(toKiloBytes(total - NumberParser.parseLong(getAttribut...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws IOException, InterruptedException { IntData performanceData = new IntData(); for (int i=0; i<50; i++) { long start = System.currentTimeMillis(); DataReader dataReader = new DataReaderS...
#fixed code public static void main(String[] args) throws IOException, InterruptedException { IntData performanceData = new IntData(); for (int i=0; i<10; i++) { long start = System.currentTimeMillis(); DataReader dataReader = new DataReaderFactory...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); In...
#fixed code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R27_SR1_full_header.txt"); gcResource.getLogg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void handleGcStart(XMLEventReader eventReader, StartElement startElement, GCEvent event) throws XMLStreamException { event.setType(Type.lookup(getAttributeValue(startElement, "type"))); if (event.getExtendedType() == null) { LOG.warni...
#fixed code private void handleGcStart(XMLEventReader eventReader, StartElement startElement, GCEvent event) throws XMLStreamException { event.setType(Type.lookup(getAttributeValue(startElement, "type"))); if (event.getExtendedType() == null) { LOG.warning("co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); In...
#fixed code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R27_SR1_full_header.txt"); gcResource.getLogg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); In...
#fixed code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R28_full_header.txt"); gcResource.getLogger()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean isParseablePhaseEvent(String line) { Matcher phaseStringMatcher = line != null ? PATTERN_INCLUDE_STRINGS_PHASE.matcher(line) : null; if (phaseStringMatcher.find()) { String phaseType = phaseStringMatcher.group(GROUP_DECORATORS...
#fixed code private boolean isParseablePhaseEvent(String line) { Matcher phaseStringMatcher = line != null ? PATTERN_INCLUDE_STRINGS_PHASE.matcher(line) : null; if (phaseStringMatcher != null && phaseStringMatcher.find()) { String phaseType = phaseStringMatche...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); In...
#fixed code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R26_GAFP1_full_header.txt"); gcResource.getLo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); In...
#fixed code @Test public void testFullHeaderWithAfGcs() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R28_full_header.txt"); gcResource.getLogger()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void loadModelIllegalArgument() throws Exception { try { dataReaderFacade.loadModel(new GcResourceFile("http://")); } catch (DataReaderException e) { assertNotNull("cause", e.getCause()); Clas...
#fixed code @Test public void loadModelIllegalArgument() throws Exception { try { dataReaderFacade.loadModel(new GcResourceFile("http://")); } catch (DataReaderException e) { assertNotNull("cause", e.getCause()); Class expe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); InputStream i...
#fixed code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R26_GAFP1_global.txt"); gcResource.getLogger().addHandle...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void setPostUsed(GCEvent event, StartElement startEl) { long total = NumberParser.parseInt(getAttributeValue(startEl, "total")); event.setPostUsed(toKiloBytes(total - NumberParser.parseInt(getAttributeValue(startEl, "free")))); } ...
#fixed code private void setPostUsed(GCEvent event, StartElement startEl) { long total = NumberParser.parseLong(getAttributeValue(startEl, "total")); event.setPostUsed(toKiloBytes(total - NumberParser.parseLong(getAttributeValue(startEl, "free")))); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); InputStream i...
#fixed code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R28_global.txt"); gcResource.getLogger().addHandler(hand...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); IMP_LOGGER.addHandler(handler); DATA_READER_FACTORY_LOGGER.addHandler(handler); InputStream i...
#fixed code @Test public void testSystemGc() throws Exception { TestLogHandler handler = new TestLogHandler(); handler.setLevel(Level.WARNING); GCResource gcResource = new GCResource("SampleIBMJ9_R26_GAFP1_global.txt"); gcResource.getLogger().addHandle...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public DataReader getDataReader(InputStream inStream) throws IOException { BufferedInputStream in = new BufferedInputStream(inStream, FOUR_KB); in.mark(FOUR_KB); byte[] buf = new byte[ONE_KB * 3]; int length = in.read(buf); in.res...
#fixed code public DataReader getDataReader(InputStream inStream) throws IOException { BufferedInputStream in = new BufferedInputStream(inStream, FOUR_KB); DataReader dataReader = null; long nextPos = 0; String chunkOfLastLine = null; int attemptCo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unused") public ListBoxModel doFillCredentialsIdItems(@QueryParameter String credentialsId) { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return new StandardListBoxModel().includeCurrentValue(credentialsId); } re...
#fixed code @SuppressWarnings("unused") public ListBoxModel doFillCredentialsIdItems(@QueryParameter String credentialsId) { return createListBoxModel(credentialsId); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static SonarQubeWebHook get() { return Jenkins.getInstance().getExtensionList(RootAction.class).get(SonarQubeWebHook.class); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public static SonarQubeWebHook get() { return Jenkins.get().getExtensionList(RootAction.class).get(SonarQubeWebHook.class); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean performInternal(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { if (!SonarInstallation.isValid(getInstallationName(), listener)) { return false; } ArgumentListBuilde...
#fixed code private boolean performInternal(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { if (!SonarInstallation.isValid(getInstallationName(), listener)) { return false; } ArgumentListBuilder args...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unused") public ListBoxModel doFillWebhookSecretIdItems(@QueryParameter String webhookSecretId) { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return new StandardListBoxModel().includeCurrentValue(webhookSecretId); } ...
#fixed code @SuppressWarnings("unused") public ListBoxModel doFillWebhookSecretIdItems(@QueryParameter String webhookSecretId) { return createListBoxModel(webhookSecretId); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String getIconFileName() { PluginWrapper wrapper = Jenkins.getInstance().getPluginManager() .getPlugin(SonarPlugin.class); return "/plugin/" + wrapper.getShortName() + "/images/waves_48x48.png"; } #location 3...
#fixed code @Override public String getIconFileName() { PluginWrapper wrapper = Jenkins.getInstanceOrNull().getPluginManager() .getPlugin(SonarPlugin.class); return "/plugin/" + wrapper.getShortName() + "/images/waves_48x48.png"; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void getQualityGate(WsClient client, ProjectInformation proj, String projectKey, float version) throws Exception { ProjectQualityGate qg; if (version < 5.2f) { qg = client.getQualityGateBefore52(projectKey); } else { qg = client.getQ...
#fixed code private static void getQualityGate(WsClient client, ProjectInformation proj, String projectKey, float version) throws Exception { ProjectQualityGate qg; if (version < 5.2f) { qg = client.getQualityGateBefore52(projectKey); } else { qg = client.getQuality...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onFirstRow (final int index, final ButtonEvent event) { if (event == ButtonEvent.DOWN) return; final CursorDeviceProxy cd = this.model.getCursorDevice (); final ModeManager modeManager = this.surface.ge...
#fixed code @Override public void onFirstRow (final int index, final ButtonEvent event) { if (event == ButtonEvent.DOWN) return; if (event == ButtonEvent.UP) { final CursorDeviceProxy cd = this.model.getCursorDevice (); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onValueKnobTouch (final int index, final boolean isTouched) { final CursorDeviceProxy cd = this.model.getCursorDevice (); final ChannelData l = cd.getSelectedLayerOrDrumPad (); this.isKnobTouched[index] = isTouched;...
#fixed code @Override public void onValueKnobTouch (final int index, final boolean isTouched) { final CursorDeviceProxy cd = this.model.getCursorDevice (); final ChannelData l = cd.getSelectedLayerOrDrumPad (); if (l == null) return; t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onFirstRow (final int index, final ButtonEvent event) { if (event == ButtonEvent.DOWN) return; final CursorDeviceProxy cd = this.model.getCursorDevice (); final ModeManager modeManager = this.surface.ge...
#fixed code @Override public void onFirstRow (final int index, final ButtonEvent event) { if (event == ButtonEvent.DOWN) return; if (event == ButtonEvent.UP) { final CursorDeviceProxy cd = this.model.getCursorDevice (); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void sendDisplayData () { if (this.usbEndpointDisplay == null) return; synchronized (this.busySendingDisplay) { final ByteBuffer displayBuffer = this.displayBlock.createByteBuffer (); displayBuffer....
#fixed code public void sendDisplayData () { if (this.hidDevice == null) return; synchronized (this.busySendingDisplay) { final ByteBuffer displayBuffer = this.displayBlock.createByteBuffer (); for (int row = 0; row < 3; r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void execute (final ButtonEvent event) { if (event != ButtonEvent.DOWN) return; final ViewManager viewManager = this.surface.getViewManager (); final AbstractTrackBankProxy tb = this.model.getCurrentTrackBank...
#fixed code @Override public void execute (final ButtonEvent event) { if (event != ButtonEvent.DOWN) return; final ViewManager viewManager = this.surface.getViewManager (); final AbstractTrackBankProxy tb = this.model.getCurrentTrackBank (); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onGridNote (final int note, final int velocity) { if (velocity == 0) return; final ICursorDevice cursorDevice = this.model.getCursorDevice (); switch (this.surface.getPadGrid ().translateToController (no...
#fixed code @Override public void onGridNote (final int note, final int velocity) { if (velocity == 0) return; final ICursorDevice cursorDevice = this.model.getCursorDevice (); final int n = this.surface.getPadGrid ().translateToController (no...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onValueKnobTouch (final int index, final boolean isTouched) { final CursorDeviceProxy cd = this.model.getCursorDevice (); final ChannelData l = cd.getSelectedLayerOrDrumPad (); this.isKnobTouched[index] = isTouched;...
#fixed code @Override public void onValueKnobTouch (final int index, final boolean isTouched) { final CursorDeviceProxy cd = this.model.getCursorDevice (); final ChannelData l = cd.getSelectedLayerOrDrumPad (); if (l == null) return; t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void moveUp () { // There is no device on the track move upwards to the track view final CursorDeviceProxy cd = this.model.getCursorDevice (); if (!cd.hasSelectedDevice ()) { this.surface.getViewManager ().getAct...
#fixed code protected void moveUp () { // There is no device on the track move upwards to the track view final CursorDeviceProxy cd = this.model.getCursorDevice (); final View activeView = this.surface.getViewManager ().getActiveView (); if (!cd.hasSel...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onValueKnobTouch (final int index, final boolean isTouched) { final CursorDeviceProxy cd = this.model.getCursorDevice (); final ChannelData l = cd.getSelectedLayerOrDrumPad (); this.isKnobTouched[index] = isTouched;...
#fixed code @Override public void onValueKnobTouch (final int index, final boolean isTouched) { final CursorDeviceProxy cd = this.model.getCursorDevice (); final ChannelData l = cd.getSelectedLayerOrDrumPad (); if (l == null) return; t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void moveUp () { // There is no device on the track move upwards to the track view final CursorDeviceProxy cd = this.model.getCursorDevice (); if (!cd.hasSelectedDevice ()) { this.surface.getViewManager ().getAct...
#fixed code protected void moveUp () { // There is no device on the track move upwards to the track view final CursorDeviceProxy cd = this.model.getCursorDevice (); final View activeView = this.surface.getViewManager ().getActiveView (); if (!cd.hasSel...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onFirstRow (final int index, final ButtonEvent event) { if (event == ButtonEvent.DOWN) return; final CursorDeviceProxy cd = this.model.getCursorDevice (); final ModeManager modeManager = this.surface.ge...
#fixed code @Override public void onFirstRow (final int index, final ButtonEvent event) { if (event == ButtonEvent.DOWN) return; if (event == ButtonEvent.UP) { final CursorDeviceProxy cd = this.model.getCursorDevice (); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Artifact chooseBinaryBits() throws MojoExecutionException { String plat; String os = System.getProperty("os.name"); getLog().debug("OS = " + os); // See here for possible values of os.name: // http://lopica.sourceforge.ne...
#fixed code private Artifact chooseBinaryBits() throws MojoExecutionException { String plat; String os = System.getProperty("os.name"); getLog().debug("OS = " + os); // See here for possible values of os.name: // http://lopica.sourceforge.net/os.h...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void setPermissions(File workdir) { if (!System.getProperty("os.name").startsWith("Windows")) { Runtime r = Runtime.getRuntime(); try { r.exec("chmod 755 " + workdir + "/bin/ld").waitFor(); r.exec("...
#fixed code private void setPermissions(File workdir) { if (!System.getProperty("os.name").startsWith("Windows")) { try { new ProcessBuilder("chmod", "755", workdir + "/bin/ld").start().waitFor(); new ProcessBuilder("chmod", "755", work...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void setPermissions(File workdir) { if (!System.getProperty("os.name").startsWith("Windows")) { Runtime r = Runtime.getRuntime(); try { r.exec("chmod 755 " + workdir + "/bin/ld").waitFor(); r.exec("...
#fixed code private void setPermissions(File workdir) { if (!System.getProperty("os.name").startsWith("Windows")) { try { new ProcessBuilder("chmod", "755", workdir + "/bin/ld").start().waitFor(); new ProcessBuilder("chmod", "755", work...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static Set<Annotation> parameterAnnotations(Member member) { Set<Annotation> result = new HashSet<>(); Annotation[][] annotations = member instanceof Method ? ((Method) member).getParameterAnnotations() : member in...
#fixed code private static Set<Annotation> parameterAnnotations(Member member) { Annotation[][] annotations = member instanceof Method ? ((Method) member).getParameterAnnotations() : member instanceof Constructor ? ((Constructor) member).getParamet...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void createMultipleSeedersWithDifferentPieces(File baseFile, int piecesCount, int pieceSize, int numSeeders, List<Client> clientList) throws IOException, InterruptedException, NoSuchAlgorithmException, URISyn...
#fixed code private void createMultipleSeedersWithDifferentPieces(File baseFile, int piecesCount, int pieceSize, int numSeeders, List<Client> clientList) throws IOException, InterruptedException, NoSuchAlgorithmException, URISyntaxExc...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void announce(AnnounceRequestMessage.RequestEvent event, boolean inhibitEvents) throws AnnounceException { logger.info("Announcing{} to tracker with {}U/{}D/{}L bytes...", new Object[] { this.formatAnnounceEvent(event), this.torrent.getUplo...
#fixed code @Override public void announce(AnnounceRequestMessage.RequestEvent event, boolean inhibitEvents) throws AnnounceException { logger.info("Announcing{} to tracker with {}U/{}D/{}L bytes...", new Object[] { this.formatAnnounceEvent(event), this.torrent.getUploaded()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getDownloaded() { return this.downloaded; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public long getDownloaded() { return myTorrentStatistic.getDownloadedBytes(); }
Below is the vulnerable code, please generate the patch based on the following information.