input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResource...
#fixed code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResourceAsStre...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void outerHtml(StringBuilder accum) { new NodeTraversor(new OuterHtmlVisitor(accum, ownerDocument().outputSettings())).traverse(this); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code protected void outerHtml(StringBuilder accum) { new NodeTraversor(new OuterHtmlVisitor(accum, getOutputSettings())).traverse(this); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean matchesWord() { return !isEmpty() && Character.isLetterOrDigit(peek()); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public boolean matchesWord() { return !isEmpty() && Character.isLetterOrDigit(queue.charAt(pos)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNextElementSiblings() { Document doc = Jsoup.parse("<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>"); Element element = doc.getElementById("a"); List<Element> elementSiblings = elem...
#fixed code @Test public void testNextElementSiblings() { Document doc = Jsoup.parse("<ul id='ul'>" + "<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>" + "</ul>" + "<div id='div'>" + "<li id...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("bo...
#fixed code public Document normalise() { Element htmlEl = findFirstElementByTagName("html", this); if (htmlEl == null) htmlEl = appendElement("html"); if (head() == null) htmlEl.prependElement("head"); if (body() == null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void removeChild(Node out) { Validate.isTrue(out.parentNode == this); int index = indexInList(out, childNodes); childNodes.remove(index); out.parentNode = null; } #location 3 ...
#fixed code protected void removeChild(Node out) { Validate.isTrue(out.parentNode == this); int index = out.siblingIndex(); childNodes.remove(index); reindexChildren(); out.parentNode = null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNextElementSiblings() { Document doc = Jsoup.parse("<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>"); Element element = doc.getElementById("a"); List<Element> elementSiblings = elem...
#fixed code @Test public void testNextElementSiblings() { Document doc = Jsoup.parse("<ul id='ul'>" + "<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>" + "</ul>" + "<div id='div'>" + "<li id...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResource...
#fixed code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResourceAsStre...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void insert(Token.Character characterToken) { final Node node; final Element el = currentElement(); final String tagName = el.normalName(); final String data = characterToken.getData(); if (characterToken.isCData()) n...
#fixed code ParseSettings defaultSettings() { return ParseSettings.htmlDefault; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void outerHtml(StringBuilder accum) { String html = StringEscapeUtils.escapeHtml(getWholeText()); if (parent() instanceof Element && !((Element) parent()).preserveWhitespace()) { html = normaliseWhitespace(html); } if (siblin...
#fixed code void outerHtmlHead(StringBuilder accum, int depth) { String html = StringEscapeUtils.escapeHtml(getWholeText()); if (parent() instanceof Element && !((Element) parent()).preserveWhitespace()) { html = normaliseWhitespace(html); } i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Document load(File in, String charsetName, String baseUri) throws IOException { InputStream inStream = new FileInputStream(in); ByteBuffer byteData = readToByteBuffer(inStream); Document doc = parseByteData(byteData, charsetName, ba...
#fixed code public static Document load(File in, String charsetName, String baseUri) throws IOException { InputStream inStream = null; try { inStream = new FileInputStream(in); ByteBuffer byteData = readToByteBuffer(inStream); return pa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String consumeCssIdentifier() { StringBuilder accum = new StringBuilder(); Character c = peek(); while (!isEmpty() && (Character.isLetterOrDigit(c) || c.equals('-') || c.equals('_'))) { accum.append(consume()); c = ...
#fixed code public String consumeCssIdentifier() { int start = pos; while (!isEmpty() && (matchesWord() || matchesAny('-', '_'))) pos++; return queue.substring(start, pos); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void replaceChild(Node out, Node in) { Validate.isTrue(out.parentNode == this); Validate.notNull(in); if (in.parentNode != null) in.parentNode.removeChild(in); Integer index = indexInList(out, childNodes); ...
#fixed code protected void replaceChild(Node out, Node in) { Validate.isTrue(out.parentNode == this); Validate.notNull(in); if (in.parentNode != null) in.parentNode.removeChild(in); Integer index = out.siblingIndex(); childNode...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void addChildren(int index, Node... children) { Validate.noNullElements(children); final List<Node> nodes = ensureChildNodes(); for (Node child : children) { reparentChild(child); } nodes.addAll(index, Array...
#fixed code protected void addChildren(int index, Node... children) { Validate.notNull(children); if (children.length == 0) { return; } final List<Node> nodes = ensureChildNodes(); // fast path - if used as a wrap (index=0, children = ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static String unescape(String string) { if (!string.contains("&")) return string; Matcher m = unescapePattern.matcher(string); // &(#(x|X)?([0-9a-fA-F]+)|[a-zA-Z]+);? StringBuffer accum = new StringBuffer(string.length()); // pity ma...
#fixed code static String unescape(String string) { if (!string.contains("&")) return string; Matcher m = unescapePattern.matcher(string); // &(#(x|X)?([0-9a-fA-F]+)|[a-zA-Z]+);? StringBuffer accum = new StringBuffer(string.length()); // pity matcher ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResource...
#fixed code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResourceAsStre...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void parseStartTag() { tq.consume("<"); Attributes attributes = new Attributes(); String tagName = tq.consumeWord(); while (!tq.matches("<") && !tq.matches("/>") && !tq.matches(">") && !tq.isEmpty()) { Attribute attri...
#fixed code private void parseStartTag() { tq.consume("<"); Attributes attributes = new Attributes(); String tagName = tq.consumeWord(); while (!tq.matchesAny("<", "/>", ">") && !tq.isEmpty()) { Attribute attribute = parseAttribute(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String ihVal(String key, Document doc) { return doc.select("th:contains(" + key + ") + td").first().text(); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code private static String ihVal(String key, Document doc) { final Element first = doc.select("th:contains(" + key + ") + td").first(); return first != null ? first.text() : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException { if (out.prettyPrint() && ((siblingIndex() == 0 && parentNode instanceof Element && ((Element) parentNode).tag().formatAsBlock() && !isBlank()) || (out.outline() && sib...
#fixed code void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException { final boolean prettyPrint = out.prettyPrint(); if (prettyPrint && ((siblingIndex() == 0 && parentNode instanceof Element && ((Element) parentNode).tag().formatAsBloc...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNamespace() throws Exception { final String namespace = "TestNamespace"; CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(...
#fixed code @Test public void testNamespace() throws Exception { final String namespace = "TestNamespace"; CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNamespaceInBackground() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPo...
#fixed code @Test public void testNamespaceInBackground() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPolicy(n...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNamespaceWithWatcher() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPol...
#fixed code @Test public void testNamespaceWithWatcher() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPolicy(ne...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i...
#fixed code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { start = start != null ? 0 : start; end = end == null ? null : end; ...
#fixed code public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { // validate & if needed pad seed if ( (seed = InputValidator.validateSeed(se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i...
#fixed code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { start = start != null ? 0 : start; end = end == null ? null : end; ...
#fixed code public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { // validate & if needed pad seed if ( (seed = InputValidator.validateSeed(se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(by...
#fixed code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(bytes); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.ge...
#fixed code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.getLogge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() throws IOException { Socket socket = serverSock.accept(); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); // TODO } #location 3 #vulnerability type RESOURCE_LEA...
#fixed code public void run() { try { final Socket socket = serverSocket.accept(); Thread th = new Thread() { public void run() { try { process.process(msgpack, socket); } catch (IOException e) { // ignore } } }; th.start(); } catch (IOExcep...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.ge...
#fixed code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.getLogge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(by...
#fixed code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(bytes); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.ge...
#fixed code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.getLogge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { while (!finished.get()) { try { final Socket socket = serverSocket.accept(); Runnable r = new Runnable() { public void run() { try { ...
#fixed code public void run() { while (!finished.get()) { try { final Socket socket = serverSocket.accept(); socket.setSoLinger(true, 0); clientSockets.add(socket); Runnable r = new Runnable() { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() throws IOException { Socket socket = serverSock.accept(); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); // TODO } #location 3 #vulnerability type RESOURCE_LEA...
#fixed code public void run() { try { final Socket socket = serverSocket.accept(); Thread th = new Thread() { public void run() { try { process.process(msgpack, socket); } catch (IOException e) { // ignore } } }; th.start(); } catch (IOExcep...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRenderMultipleObjects() { TestObject testObject = new TestObject(); // step 1: add one object. Result result = new Result(200); result.render(testObject); assertEqual...
#fixed code @Test public void testRenderMultipleObjects() { TestObject testObject = new TestObject(); // step 1: add one object. Result result = new Result(200); result.render(testObject); assertEquals(test...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRenderingOfStringObjectPairsWorks() { String object1 = new String("stringy1"); String object2 = new String("stringy2"); // step 1: add one object. Result result = new Result(200); result.render...
#fixed code @Test public void testRenderingOfStringObjectPairsWorks() { String object1 = new String("stringy1"); String object2 = new String("stringy2"); // step 1: add one object. Result result = new Result(200); result.render("obje...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String makeJsonRequest(String url) { StringBuffer sb = new StringBuffer(); try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet getRequest = new HttpGet(url); getRequest.addHeader("accept", "application/json"); HttpResponse...
#fixed code public static String makeJsonRequest(String url) { Map<String, String> headers = Maps.newHashMap(); headers.put("accept", "application/json"); return makeRequest(url, headers); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void parse() { Map<String,RouteParameter> params; RouteParameter param; // no named parameters is null params = RouteParameter.parse("/user"); assertThat(params, is(nullValue())); params ...
#fixed code @Test public void parse() { Map<String,RouteParameter> params; RouteParameter param; // no named parameters is null params = RouteParameter.parse("/user"); assertThat(params, aMapWithSize(0)); params = Rout...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRenderEntryAndMakeSureMapIsCreated() { String stringy = new String("stringy"); Entry<String, Object> entry = new SimpleImmutableEntry("stringy", stringy); // step 1: add one object. ...
#fixed code @Test public void testRenderEntryAndMakeSureMapIsCreated() { String stringy = new String("stringy"); // step 1: add one object. Result result = new Result(200); result.render("stringy", stringy); Map<String, Object> resul...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static private SourceSnippet readFromInputStream(InputStream is, URI source, int lineFrom, int lineTo)...
#fixed code static private SourceSnippet readFromInputStream(InputStream is, URI source, int lineFrom, int lineTo) throw...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String makeRequest(String url, Map<String, String> headers) { StringBuffer sb = new StringBuffer(); try { HttpGet getRequest = new HttpGet(url); if (headers != null) { // add all headers f...
#fixed code public String makeRequest(String url, Map<String, String> headers) { StringBuffer sb = new StringBuffer(); BufferedReader br = null; try { HttpGet getRequest = new HttpGet(url); if (headers != null) { // add a...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void handleTemplateException(TemplateException te, Environment env, Writer out) { if (ninjaProperties.isProd()) { PrintWriter pw = (out instanceof Pr...
#fixed code public void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException { if (!ninjaProperties.isProd()) { // print out full stacktrace...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object invoke(MethodInvocation invocation) throws Throwable { final UnitOfWork unitOfWork; // Only start a new unit of work if the entitymanager is empty // otherwise someone else has started the unit of wor...
#fixed code @Override public Object invoke(MethodInvocation invocation) throws Throwable { if (null == didWeStartWork.get()) { unitOfWork.begin(); didWeStartWork.set(Boolean.TRUE); } else { // If u...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String makePostRequestWithFormParameters(String url, Map<String, String> headers, Map<String, String> formParameters) { StringBuffer sb = new StringBu...
#fixed code public String makePostRequestWithFormParameters(String url, Map<String, String> headers, Map<String, String> formParameters) { StringBuffer sb = new StringBuffer()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAllConstants() { Configuration configuration = SwissKnife.loadConfigurationFromClasspathInUtf8("conf/all_constants.conf", this .getClass()); assertEquals("LANGUAGES", configurat...
#fixed code @Test public void testAllConstants() { Configuration configuration = SwissKnife.loadConfigurationInUtf8("conf/all_constants.conf"); assertEquals("LANGUAGES", configuration.getString(NinjaConstant.applicationLanguages)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean runSteps(FlowSpec scenario, FlowStepStatusNotifier flowStepStatusNotifier) { ScenarioExecutionState scenarioExecutionState = new ScenarioExecutionState(); for(Step thisStep : scenario.getSteps()){ // Another way...
#fixed code @Override public boolean runSteps(FlowSpec scenario, FlowStepStatusNotifier flowStepStatusNotifier) { LOGGER.info("\n-------------------------- Scenario:{} -------------------------\n", scenario.getFlowName()); ScenarioExecutionState scenarioExecutionSta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRawRecordingSpeed() throws Exception { Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits); // Warm up: long startTime = System.nanoTime(); recordLoop(histogram, warmupLoopL...
#fixed code @Test public void testRawRecordingSpeed() throws Exception { testRawRecordingSpeedAtExpectedInterval(1000000000); testRawRecordingSpeedAtExpectedInterval(10000); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static synchronized List<Menu> loadJson() throws IOException { InputStream inStream = MenuJsonUtils.class.getResourceAsStream(config); BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, Charset.forName("UTF-8"))); ...
#fixed code private static synchronized List<Menu> loadJson() throws IOException { InputStream inStream = MenuJsonUtils.class.getResourceAsStream(config); BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, Charset.forName("UTF-8"))); Strin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, HandlerMethod handler, ModelAndView modelAndView) throws Exception { PostVO ret = (PostVO) modelAndView.getModelMap().get("view"); Object editing = modelAndVie...
#fixed code @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, HandlerMethod handler, ModelAndView modelAndView) throws Exception { PostVO ret = (PostVO) modelAndView.getModelMap().get("view"); Object editing = modelAndView.getM...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { // STEP-1: read input parameters and validate them if (args.length < 2) { System.err.println("Usage: SecondarySortUsingGroupByKey <input> <output>"); System.exit(1); } String inpu...
#fixed code public static void main(String[] args) throws Exception { // STEP-1: read input parameters and validate them if (args.length < 2) { System.err.println("Usage: SecondarySortUsingGroupByKey <input> <output>"); System.exit(1); } String inputPath ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Map<String, String> readService(String path) throws IOException { InputStreamReader fr = new InputStreamReader(FileUtil.class.getResourceAsStream(path)); BufferedReader br = new BufferedReader(fr); String line = ""; Map<String, String> result...
#fixed code public static Map<String, String> readService(String path) throws IOException { InputStreamReader fr = new InputStreamReader(FileUtil.class.getResourceAsStream(path),Constant.ENCODING_UTF_8); BufferedReader br = new BufferedReader(fr); String line; Map<String, S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static CacheManager get() { if (instance == null) { synchronized (log) { if (instance == null) { instance = new CacheManager(); } } } return instance; } #location 9 ...
#fixed code public static CacheManager get() { return get(defaultCacheManager); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings({"unchecked", "rawtypes"}) public void onReceive(ServiceContext serviceContext) throws Throwable { FlowMessage fm = serviceContext.getFlowMessage(); if (serviceContext.isSync() && !syncActors.containsKey(serviceContext.getId())) { syncAct...
#fixed code @SuppressWarnings({"unchecked", "rawtypes"}) public void onReceive(ServiceContext serviceContext) throws Throwable { FlowMessage fm = serviceContext.getFlowMessage(); if (serviceContext.isSync() && !syncActors.containsKey(serviceContext.getId())) { syncActors.pu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("ServiceFlow [\r\n\tflowName = "); builder.append(flowName); builder.append("\r\n\t"); Set<ServiceConfig> nextServices = servicesOfFlow.get(getHeadServic...
#fixed code @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("ServiceFlow [ flowName = "); builder.append(flowName); builder.append("\r\n\t"); ServiceConfig hh = header; buildString(hh, builder); builder.append(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void onServiceContextReceived(ServiceContext serviceContext) throws Throwable { FlowMessage flowMessage = serviceContext.getFlowMessage(); if (serviceContext.isSync()) { CacheManager.get(servi...
#fixed code @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void onServiceContextReceived(ServiceContext serviceContext) throws Throwable { FlowMessage flowMessage = serviceContext.getFlowMessage(); if (serviceContext.isSync()) { CacheManager.get(serviceActo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doStartup(String configLocation) { ClassPathXmlApplicationContext applicationContext = null; try { applicationContext = new ClassPathXmlApplicationContext(configLocation); applicationContext.start(); } catch (Exception e) {...
#fixed code @Override public void doStartup(String configLocation) throws Throwable { Class<?> applicationContextClazz = Class.forName("org.springframework.context.support.ClassPathXmlApplicationContext", true, getClassLoader()); Object flowerFactory = applicationContextC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static List<Pair<String, String>> readFlow(String path) throws IOException { InputStreamReader fr = new InputStreamReader(FileUtil.class.getResourceAsStream(path)); BufferedReader br = new BufferedReader(fr); String line = ""; List<Pair<String, Stri...
#fixed code public static List<Pair<String, String>> readFlow(String path) throws IOException { InputStreamReader fr = new InputStreamReader(FileUtil.class.getResourceAsStream(path),Constant.ENCODING_UTF_8); BufferedReader br = new BufferedReader(fr); String line; List<Pair...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean isEquivalentTo(JSType otherType) { if (!(otherType instanceof FunctionType)) { return false; } FunctionType that = (FunctionType) otherType; if (!that.isFunctionType()) { return false; } if (this.isConstructor...
#fixed code @Override public boolean isEquivalentTo(JSType otherType) { FunctionType that = JSType.toMaybeFunctionType(otherType.toMaybeFunctionType()); if (that == null) { return false; } if (this.isConstructor()) { if (that.isConstructor()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code FunctionTypeBuilder inferThisType(JSDocInfo info, @Nullable Node owner) { ObjectType maybeThisType = null; if (info != null && info.hasThisType()) { maybeThisType = ObjectType.cast( info.getThisType().evaluate(scope, typeRegistry)); } ...
#fixed code FunctionTypeBuilder(String fnName, AbstractCompiler compiler, Node errorRoot, String sourceName, Scope scope) { Preconditions.checkNotNull(errorRoot); this.fnName = fnName == null ? "" : fnName; this.codingConvention = compiler.getCodingConvention(); this...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private EnvTypePair analyzeLooseCallNodeBwd( Node callNode, TypeEnv outEnv, JSType retType) { Preconditions.checkArgument(callNode.isCall()); Preconditions.checkNotNull(retType); Node callee = callNode.getFirstChild(); TypeEnv tmpEnv = outEnv; Fu...
#fixed code private EnvTypePair analyzeLooseCallNodeBwd( Node callNode, TypeEnv outEnv, JSType retType) { Preconditions.checkArgument(callNode.isCall()); Preconditions.checkNotNull(retType); Node callee = callNode.getFirstChild(); TypeEnv tmpEnv = outEnv; Function...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<JSSourceFile> getDefaultExterns() { try { InputStream input = Compiler.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); List<JSSourceFile> externs = Lists.newLinkedList(); for (...
#fixed code private List<JSSourceFile> getDefaultExterns() { try { return CommandLineRunner.getDefaultExterns(); } catch (IOException e) { throw new BuildException(e); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node tryOptimizeSwitch(Node n) { Preconditions.checkState(n.getType() == Token.SWITCH); Node defaultCase = findDefaultCase(n); if (defaultCase != null && isUselessCase(defaultCase)) { NodeUtil.redeclareVarsInsideBranch(defaultCase); n.remo...
#fixed code private Node tryOptimizeSwitch(Node n) { Preconditions.checkState(n.getType() == Token.SWITCH); Node defaultCase = tryOptimizeDefaultCase(n); // Removing cases when there exists a default case is not safe. if (defaultCase == null) { Node next = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void writeResult(String source) { if (this.outputFile.getParentFile().mkdirs()) { log("Created missing parent directory " + this.outputFile.getParentFile(), Project.MSG_DEBUG); } try { FileWriter out = new FileWriter(this.outputF...
#fixed code private void writeResult(String source) { if (this.outputFile.getParentFile().mkdirs()) { log("Created missing parent directory " + this.outputFile.getParentFile(), Project.MSG_DEBUG); } try { OutputStreamWriter out = new OutputStreamWriter( ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Writer fileNameToOutputWriter(String fileName) throws IOException { if (fileName == null) { return null; } if (testMode) { return new StringWriter(); } return streamToOutputWriter(new FileOutputStream(fileName)); } ...
#fixed code private Writer fileNameToOutputWriter(String fileName) throws IOException { if (fileName == null) { return null; } if (testMode) { return new StringWriter(); } return streamToOutputWriter(filenameToOutputStream(fileName)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<INPUT> getSortedDependenciesOf(List<INPUT> roots) { Preconditions.checkArgument(inputs.containsAll(roots)); Set<INPUT> included = Sets.newHashSet(); Deque<INPUT> worklist = new ArrayDeque<INPUT>(roots); while (!worklist.isEmpty()) { INPUT...
#fixed code public List<INPUT> getSortedDependenciesOf(List<INPUT> roots) { return getDependenciesOf(roots, true); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. ...
#fixed code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. Node...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) { if (n.isScript()) { this.inExterns = n.getStaticSourceFile().isExtern(); } return true; } #location 4 #vulnerabi...
#fixed code @Override public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) { return true; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Set<String> getOwnPropertyNames() { return ImmutableSet.of(); } #location 1 #vulnerability type CHECKERS_IMMUTABLE_CAST
#fixed code public Set<String> getOwnPropertyNames() { return getPropertyMap().getOwnPropertyNames(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void enterScope(NodeTraversal t) { new GraphReachability<Node, ControlFlowGraph.Branch>( t.getControlFlowGraph(), new ReachablePredicate()).compute( t.getControlFlowGraph().getEntry().getValue()); } ...
#fixed code @Override public void enterScope(NodeTraversal t) { scopeNeedsInit = true; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initEdgeEnvsFwd() { // TODO(user): Revisit what we throw away after the bwd analysis DiGraphNode<Node, ControlFlowGraph.Branch> entry = cfg.getEntry(); DiGraphEdge<Node, ControlFlowGraph.Branch> entryOutEdge = cfg.getOutEdges(entry.getValu...
#fixed code private void initEdgeEnvsFwd() { // TODO(user): Revisit what we throw away after the bwd analysis DiGraphNode<Node, ControlFlowGraph.Branch> entry = cfg.getEntry(); DiGraphEdge<Node, ControlFlowGraph.Branch> entryOutEdge = cfg.getOutEdges(entry.getValue()).g...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void removeUnreferencedVars() { CodingConvention convention = compiler.getCodingConvention(); for (Iterator<Var> it = maybeUnreferenced.iterator(); it.hasNext(); ) { Var var = it.next(); // Regardless of what happens to the original declarati...
#fixed code private void removeUnreferencedVars() { CodingConvention convention = codingConvention; for (Iterator<Var> it = maybeUnreferenced.iterator(); it.hasNext(); ) { Var var = it.next(); // Remove calls to inheritance-defining functions where the unreferenced ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. ...
#fixed code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. Node...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void outputTracerReport() { OutputStreamWriter output = new OutputStreamWriter(this.err); try { int runtime = 0; int runs = 0; int changes = 0; int diff = 0; int gzDiff = 0; // header output.write("Summary:\n"); ...
#fixed code private void outputTracerReport() { JvmMetrics.maybeWriteJvmMetrics(this.err, "verbose:pretty:all"); OutputStreamWriter output = new OutputStreamWriter(this.err); try { int runtime = 0; int runs = 0; int changes = 0; int diff = 0; int ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void escapeParameters(MustDef output) { for (Iterator<Var> i = jsScope.getVars(); i.hasNext();) { Var v = i.next(); if (v.getParentNode().getType() == Token.LP) { // Assume we no longer know where the parameter comes from // anymore...
#fixed code private void escapeParameters(MustDef output) { for (Iterator<Var> i = jsScope.getVars(); i.hasNext();) { Var v = i.next(); if (isParameter(v)) { // Assume we no longer know where the parameter comes from // anymore. output.reachingDef.pu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void enterScope(NodeTraversal t) { Scope scope = t.getScope(); // Computes the control flow graph. ControlFlowAnalysis cfa = new ControlFlowAnalysis(compiler, false, false); cfa.process(null, scope.getRootNode()); cfgStack.push(curC...
#fixed code @Override public void enterScope(NodeTraversal t) {}
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void enterScope(NodeTraversal t) { // TODO(user): We CAN do this in the global scope, just need to be // careful when something is exported. Liveness uses bit-vector for live // sets so I don't see compilation time will be a problem for runn...
#fixed code @Override public void enterScope(NodeTraversal t) { Scope scope = t.getScope(); if (!shouldOptimizeScope(scope)) { return; } ControlFlowGraph<Node> cfg = t.getControlFlowGraph(); LiveVariablesAnalysis liveness = new LiveVariablesAnalysis(cfg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String getFunctionAnnotation(Node fnNode) { Preconditions.checkState(fnNode.getType() == Token.FUNCTION); StringBuilder sb = new StringBuilder("/**\n"); JSType type = fnNode.getJSType(); if (type == null || type.isUnknownType()) { return ""...
#fixed code private String getFunctionAnnotation(Node fnNode) { Preconditions.checkState(fnNode.getType() == Token.FUNCTION); StringBuilder sb = new StringBuilder("/**\n"); JSType type = fnNode.getJSType(); if (type == null || type.isUnknownType()) { return ""; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node inlineReturnValue(Node callNode, Node fnNode) { Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new n...
#fixed code private Node inlineReturnValue(Node callNode, Node fnNode) { Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new names, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code FunctionTypeBuilder inferThisType(JSDocInfo info, @Nullable Node owner) { ObjectType maybeThisType = null; if (info != null && info.hasThisType()) { maybeThisType = ObjectType.cast( info.getThisType().evaluate(scope, typeRegistry)); } ...
#fixed code FunctionTypeBuilder(String fnName, AbstractCompiler compiler, Node errorRoot, String sourceName, Scope scope) { Preconditions.checkNotNull(errorRoot); this.fnName = fnName == null ? "" : fnName; this.codingConvention = compiler.getCodingConvention(); this...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void createPropertyScopeFor(Symbol s) { // In order to build a property scope for s, we will need to build // a property scope for all its implicit prototypes first. This means // that sometimes we will already have built its property scope // for ...
#fixed code private void createPropertyScopeFor(Symbol s) { // In order to build a property scope for s, we will need to build // a property scope for all its implicit prototypes first. This means // that sometimes we will already have built its property scope // for a prev...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private FlowScope traverse(Node n, FlowScope scope) { switch (n.getType()) { case Token.ASSIGN: scope = traverseAssign(n, scope); break; case Token.NAME: scope = traverseName(n, scope); break; case Token.GETPROP: ...
#fixed code private FlowScope traverse(Node n, FlowScope scope) { switch (n.getType()) { case Token.ASSIGN: scope = traverseAssign(n, scope); break; case Token.NAME: scope = traverseName(n, scope); break; case Token.GETPROP: s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node inlineReturnValue(Node callNode, Node fnNode) { Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new n...
#fixed code private Node inlineReturnValue(Node callNode, Node fnNode) { Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new names, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private UndiGraph<Var, Void> computeVariableNamesInterferenceGraph( NodeTraversal t, ControlFlowGraph<Node> cfg, Set<Var> escaped) { UndiGraph<Var, Void> interferenceGraph = LinkedUndirectedGraph.create(); Scope scope = t.getScope(); // First cr...
#fixed code private UndiGraph<Var, Void> computeVariableNamesInterferenceGraph( NodeTraversal t, ControlFlowGraph<Node> cfg, Set<Var> escaped) { UndiGraph<Var, Void> interferenceGraph = LinkedUndirectedGraph.create(); // For all variables V not in unsafeCrossRange, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Symbol getSymbolForInstancesOf(FunctionType fn) { Preconditions.checkState(fn.isConstructor() || fn.isInterface()); ObjectType pType = fn.getPrototype(); String name = pType.getReferenceName(); if (name == null || globalScope == null) { return...
#fixed code public Symbol getSymbolForInstancesOf(FunctionType fn) { Preconditions.checkState(fn.isConstructor() || fn.isInterface()); ObjectType pType = fn.getPrototype(); return getSymbolForName(fn.getSource(), pType.getReferenceName()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void enterScope(NodeTraversal t) { Scope scope = t.getScope(); // Computes the control flow graph. ControlFlowAnalysis cfa = new ControlFlowAnalysis(compiler, false, false); cfa.process(null, scope.getRootNode()); cfgStack.push(curC...
#fixed code @Override public void enterScope(NodeTraversal t) {}
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. ...
#fixed code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. Node...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void removeUnreferencedVars() { CodingConvention convention = compiler.getCodingConvention(); for (Iterator<Var> it = maybeUnreferenced.iterator(); it.hasNext(); ) { Var var = it.next(); // Regardless of what happens to the original declarati...
#fixed code private void removeUnreferencedVars() { CodingConvention convention = codingConvention; for (Iterator<Var> it = maybeUnreferenced.iterator(); it.hasNext(); ) { Var var = it.next(); // Remove calls to inheritance-defining functions where the unreferenced ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. ...
#fixed code private Node aliasAndInlineArguments( Node fnTemplateRoot, LinkedHashMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. Node...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static List<JSSourceFile> getDefaultExterns() throws IOException { InputStream input = CommandLineRunner.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); Map<String, JSSourceFile> externsMap = Maps.newH...
#fixed code public static List<JSSourceFile> getDefaultExterns() throws IOException { InputStream input = CommandLineRunner.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); Map<String, JSSourceFile> externsMap = Maps.newHashMap...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code int processResults(Result result, List<JSModule> modules, B options) throws FlagUsageException, IOException { if (config.computePhaseOrdering) { return 0; } if (config.printPassGraph) { if (compiler.getRoot() == null) { return 1; ...
#fixed code AbstractCommandLineRunner() { this(System.out, System.err); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code Node tryFoldFor(Node n) { Preconditions.checkArgument(n.getType() == Token.FOR); // This is not a FOR-IN loop if (n.getChildCount() != 4) { return n; } // There isn't an initializer if (n.getFirstChild().getType() != Token.EMPTY) { retu...
#fixed code Node tryOptimizeBlock(Node n) { // Remove any useless children for (Node c = n.getFirstChild(); c != null; ) { Node next = c.getNext(); // save c.next, since 'c' may be removed if (!mayHaveSideEffects(c)) { // TODO(johnlenz): determine what this is ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void outputManifest() throws IOException { String outputManifest = config.outputManifest; if (Strings.isEmpty(outputManifest)) { return; } JSModuleGraph graph = compiler.getModuleGraph(); if (shouldGenerateManifestPerModule()) { //...
#fixed code private void outputManifest() throws IOException { List<String> outputManifests = config.outputManifests; if (outputManifests.isEmpty()) { return; } for (String outputManifest : outputManifests) { if (outputManifest.isEmpty()) { continue; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node inlineReturnValue(Node callNode, Node fnNode) { Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new n...
#fixed code private Node inlineReturnValue(Node callNode, Node fnNode) { Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new names, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void process(Node externs, Node root) { Map<String, TweakInfo> tweakInfos = collectTweaks(root); applyCompilerDefaultValueOverrides(tweakInfos); boolean changed = false; if (stripTweaks) { changed = stripAllCalls(tweakInfos); ...
#fixed code @Override public void process(Node externs, Node root) { CollectTweaksResult result = collectTweaks(root); applyCompilerDefaultValueOverrides(result.tweakInfos); boolean changed = false; if (stripTweaks) { changed = stripAllCalls(result.tweakInfos); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node fuseIntoOneStatement(Node parent, Node first, Node last) { // Nothing to fuse if there is only one statement. if (first == last) { return first; } // Step one: Create a comma tree that contains all the statements. Node commaTree = f...
#fixed code private Node fuseIntoOneStatement(Node parent, Node first, Node last) { // Nothing to fuse if there is only one statement. if (first.getNext() == last) { return first; } // Step one: Create a comma tree that contains all the statements. Node commaTree...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code FunctionTypeBuilder inferReturnType(@Nullable JSDocInfo info) { if (info != null && info.hasReturnType()) { returnType = info.getReturnType().evaluate(scope, typeRegistry); returnTypeInferred = false; } return this; } ...
#fixed code FunctionTypeBuilder(String fnName, AbstractCompiler compiler, Node errorRoot, String sourceName, Scope scope) { Preconditions.checkNotNull(errorRoot); this.fnName = fnName == null ? "" : fnName; this.codingConvention = compiler.getCodingConvention(); this...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void analyzeFunctionBwd( List<DiGraphNode<Node, ControlFlowGraph.Branch>> workset) { for (DiGraphNode<Node, ControlFlowGraph.Branch> dn : workset) { Node n = dn.getValue(); TypeEnv outEnv = getOutEnv(n); TypeEnv inEnv; System.out....
#fixed code private void analyzeFunctionBwd( List<DiGraphNode<Node, ControlFlowGraph.Branch>> workset) { for (DiGraphNode<Node, ControlFlowGraph.Branch> dn : workset) { Node n = dn.getValue(); if (n.isThrow()) { // Throw statements have no out edges. // TODO(b...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code int processResults(Result result, List<JSModule> modules, B options) throws FlagUsageException, IOException { if (config.computePhaseOrdering) { return 0; } if (config.printPassGraph) { if (compiler.getRoot() == null) { return 1; ...
#fixed code AbstractCommandLineRunner() { this(System.out, System.err); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void ensureTyped(NodeTraversal t, Node n, JSType type) { // Make sure FUNCTION nodes always get function type. Preconditions.checkState(!n.isFunction() || type.isFunctionType() || type.isUnknownType()); JSDocInfo info = n.getJSD...
#fixed code private void ensureTyped(NodeTraversal t, Node n, JSType type) { // Make sure FUNCTION nodes always get function type. Preconditions.checkState(!n.isFunction() || type.isFunctionType() || type.isUnknownType()); // TODO(johnlenz): this seems l...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void outputManifest() throws IOException { String outputManifest = config.outputManifest; if (Strings.isEmpty(outputManifest)) { return; } JSModuleGraph graph = compiler.getModuleGraph(); if (shouldGenerateManifestPerModule()) { //...
#fixed code private void outputManifest() throws IOException { List<String> outputManifests = config.outputManifests; if (outputManifests.isEmpty()) { return; } for (String outputManifest : outputManifests) { if (outputManifest.isEmpty()) { continue; ...
Below is the vulnerable code, please generate the patch based on the following information.