input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Override public Event applySetIntSet(RedisInputStream in, DB db, int version) throws IOException { /* * |<encoding>| <length-of-contents>| <contents> | * | 4 bytes | 4 bytes | 2 bytes lem...
#fixed code @Override public Event applySetIntSet(RedisInputStream in, DB db, int version) throws IOException { /* * |<encoding>| <length-of-contents>| <contents> | * | 4 bytes | 4 bytes | 2 bytes lement| 4...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State generateState(String comment, Path rootDir, Path dirToScan) throws NoSuchAlgorithmException { this.rootDir = rootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(context.getHashMode()), context.getT...
#fixed code public State generateState(String comment, Path rootDir, Path dirToScan) throws NoSuchAlgorithmException { this.rootDir = rootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(context.getHashMode()), context.getThreadC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws IOException, NoSuchAlgorithmException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (co...
#fixed code public static void main(String[] args) throws IOException, NoSuchAlgorithmException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (command ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State loadState(int stateNumber) throws IOException { File stateFile = getStateFile(stateNumber); if (!stateFile.exists()) { throw new IllegalStateException(String.format("Unable to load State file %d from directory %s", stateNumber, stateDir)); } Sta...
#fixed code public State loadState(int stateNumber) throws IOException { File stateFile = getStateFile(stateNumber); if (!stateFile.exists()) { throw new IllegalStateException(String.format("Unable to load State file %d from directory %s", stateNumber, stateDir)); } State sta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws IOException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (command == null) { youM...
#fixed code public static void main(String[] args) throws IOException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (command == null) { youMustSpe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public DuplicateResult findDuplicates(State state) { DuplicateResult result = new DuplicateResult(parameters); List<FileState> fileStates = new ArrayList<>(state.getFileStates()); Collections.sort(fileStates, fullHashComparator); FileHash previousHash = new File...
#fixed code public DuplicateResult findDuplicates(State state) { DuplicateResult result = new DuplicateResult(parameters); List<FileState> fileStates = new ArrayList<>(state.getFileStates()); Collections.sort(fileStates, hashComparator); List<FileState> duplicatedFiles = new Arra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws IOException, NoSuchAlgorithmException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (co...
#fixed code public static void main(String[] args) throws IOException, NoSuchAlgorithmException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (command ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State generateState(String comment, Path fimRepositoryRootDir) throws IOException, NoSuchAlgorithmException { this.fimRepositoryRootDir = fimRepositoryRootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(...
#fixed code public State generateState(String comment, Path fimRepositoryRootDir) throws IOException, NoSuchAlgorithmException { this.fimRepositoryRootDir = fimRepositoryRootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(), par...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State generateState(String comment, Path rootDir, Path dirToScan) throws NoSuchAlgorithmException { this.rootDir = rootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(context.getHashMode()), context.getT...
#fixed code public State generateState(String comment, Path rootDir, Path dirToScan) throws NoSuchAlgorithmException { this.rootDir = rootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(context.getHashMode()), context.getThreadC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void outputInit() { summedFileLength = 0; fileCount = 0; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void outputInit() { progressLock.lock(); try { summedFileLength = 0; fileCount = 0; } finally { progressLock.unlock(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State loadState(int stateNumber) throws IOException { File stateFile = getStateFile(stateNumber); if (!stateFile.exists()) { throw new IllegalStateException(String.format("Unable to load State file %d from directory %s", stateNumber, stateDir)); } Sta...
#fixed code public State loadState(int stateNumber) throws IOException { File stateFile = getStateFile(stateNumber); if (!stateFile.exists()) { throw new IllegalStateException(String.format("Unable to load State file %d from directory %s", stateNumber, stateDir)); } State sta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean resetDosPermissions(Path file, FileState fileState, DosFileAttributes dosFileAttributes) { String permissions = DosFilePermissions.toString(dosFileAttributes); String previousPermissions = getAttribute(fileState, FileAttribute.DosFilePermissions); if...
#fixed code private boolean resetDosPermissions(Path file, FileState fileState, DosFileAttributes dosFileAttributes) { String permissions = DosFilePermissions.toString(dosFileAttributes); String previousPermissions = getAttribute(fileState, FileAttribute.DosFilePermissions); if (prev...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State generateState(String comment, Path fimRepositoryRootDir) throws IOException, NoSuchAlgorithmException { this.fimRepositoryRootDir = fimRepositoryRootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(...
#fixed code public State generateState(String comment, Path fimRepositoryRootDir) throws IOException, NoSuchAlgorithmException { this.fimRepositoryRootDir = fimRepositoryRootDir; Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(), par...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void displayDifferences(PrintStream out, Context context, String actionStr, List<Difference> differences, Consumer<Difference> displayOneDifference) { int truncateOutput = context.getTruncateOutput(); ...
#fixed code public static void displayDifferences(PrintStream out, Context context, String actionStr, List<Difference> differences, Consumer<Difference> displayOneDifference) { int truncateOutput = context.getTruncateOutput(); if ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State loadState(int stateNumber) throws IOException { File stateFile = getStateFile(stateNumber); if (!stateFile.exists()) { throw new IllegalStateException(String.format("Unable to load State file %d from directory %s", stateNumber, stateDir)); } Sta...
#fixed code public State loadState(int stateNumber) throws IOException { File stateFile = getStateFile(stateNumber); if (!stateFile.exists()) { throw new IllegalStateException(String.format("Unable to load State file %d from directory %s", stateNumber, stateDir)); } State sta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public State generateState(String comment, File fimRepositoryRootDir) throws IOException, NoSuchAlgorithmException { Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(), parameters.getThreadCount())); System.out.printf...
#fixed code public State generateState(String comment, File fimRepositoryRootDir) throws IOException, NoSuchAlgorithmException { Logger.info(String.format("Scanning recursively local files, %s, using %d thread", hashModeToString(), parameters.getThreadCount())); System.out.printf(" ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + last...
#fixed code public CompareResult displayChanges() { if (lastState != null) { System.out.printf("Comparing with the last committed state from %s%n", formatDate(lastState.getTimestamp())); if (lastState.getComment().length() > 0) { System.out.println("Comment: " + lastState....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void outputInit() { summedFileLength = 0; fileCount = 0; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void outputInit() { progressLock.lock(); try { summedFileLength = 0; fileCount = 0; } finally { progressLock.unlock(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws IOException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (command == null) { youM...
#fixed code public static void main(String[] args) throws IOException { String[] filteredArgs = filterEmptyArgs(args); if (filteredArgs.length < 1) { youMustSpecifyACommandToRun(); } Command command = Command.fromName(filteredArgs[0]); if (command == null) { youMustSpe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int getNumberOfFeatures(){ List<?> coefs = getCoefs(); NDArray input = (NDArray)coefs.get(0); int[] shape = NDArrayUtil.getShape(input); return shape[0]; } #location 5 #vulnerability ty...
#fixed code @Override public int getNumberOfFeatures(){ List<? extends HasArray> coefs = getCoefs(); return NeuralNetworkUtil.getNumberOfFeatures(coefs); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Expression encode(int index, FieldName name){ Expression expression = new FieldRef(name); if(withMean()){ Number mean = Iterables.get(getMean(), index); if(Double.compare(mean.doubleValue(), 0d) != 0){ expression = PMMLUtil.createApply("-"...
#fixed code @Override public Expression encode(int index, FieldName name){ Expression expression = new FieldRef(name); if(getWithMean()){ Number mean = Iterables.get(getMean(), index); if(Double.compare(mean.doubleValue(), 0d) != 0){ expression = PMMLUtil.createApply("-", e...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<? extends Number> getNodeAttribute(String key){ NDArrayWrapper nodes = (NDArrayWrapper)get("nodes"); Map<String, ?> content = (Map<String, ?>)nodes.getContent(); return (List<? extends Number>)content.get(key); } #location...
#fixed code private List<? extends Number> getNodeAttribute(String key){ List<? extends Number> nodeAttributes = (List<? extends Number>)ClassDictUtil.getArray(this, "nodes", key); return nodeAttributes; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public List<?> getArray(ClassDict dict, String name, String key){ NDArrayWrapper arrayWrapper = (NDArrayWrapper)dict.get(name); NDArray array = arrayWrapper.getContent(); return NDArrayUtil.getData(array, key); } #location 5 ...
#fixed code static public List<?> getArray(ClassDict dict, String name, String key){ Object object = dict.get(name); if(object instanceof NDArrayWrapper){ NDArrayWrapper arrayWrapper = (NDArrayWrapper)object; NDArray array = arrayWrapper.getContent(); return NDArrayUtil.get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public List<?> getArray(ClassDict dict, String name, String key){ NDArrayWrapper nodes = (NDArrayWrapper)dict.get(name); Map<String, ?> content = (Map<String, ?>)nodes.getContent(); return toArray(content.get(key)); } #location...
#fixed code static public List<?> getArray(ClassDict dict, String name, String key){ NDArrayWrapper arrayWrapper = (NDArrayWrapper)dict.get(name); NDArray array = arrayWrapper.getContent(); return NDArrayUtil.getData(array, key); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Expression encode(int index, FieldName name){ Expression expression = new FieldRef(name); if(withMean()){ Number mean = Iterables.get(getMean(), index); if(Double.compare(mean.doubleValue(), 0d) != 0){ expression = PMMLUtil.createApply("-"...
#fixed code @Override public Expression encode(int index, FieldName name){ Expression expression = new FieldRef(name); if(getWithMean()){ Number mean = Iterables.get(getMean(), index); if(Double.compare(mean.doubleValue(), 0d) != 0){ expression = PMMLUtil.createApply("-", e...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Object[] getEstimatorStep(){ List<Object[]> steps = getSteps(); if(steps.size() < 1){ throw new IllegalArgumentException("Missing estimator step"); } return steps.get(steps.size() - 1); } #location 4 ...
#fixed code protected Object[] getEstimatorStep(){ List<Object[]> steps = getSteps(); if(steps == null || steps.size() < 1){ throw new IllegalArgumentException("Missing estimator step"); } return steps.get(steps.size() - 1); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Object[]> getTransformerSteps(){ List<Object[]> steps = getSteps(); if(steps.size() < 1){ throw new IllegalArgumentException("Missing estimator step"); } return steps.subList(0, steps.size() - 1); } #location 4 ...
#fixed code public List<Object[]> getTransformerSteps(){ List<Object[]> steps = getSteps(); if(steps == null || steps.size() < 1){ throw new IllegalArgumentException("Missing estimator step"); } return steps.subList(0, steps.size() - 1); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object getFill(){ return asJavaObject(get("fill_")); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public Object getFill(){ return getScalar("fill_"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public PMML encodePMML(){ List<DataField> dataFields = new ArrayList<>(); DataField targetDataField = encodeTarget(); dataFields.add(targetDataField); Integer features = getFeatures(); for(int i = 0; i < features.intValue(); i++){ DataField dataField = new D...
#fixed code public PMML encodePMML(){ List<DataField> dataFields = new ArrayList<>(); dataFields.add(encodeTargetField()); int features = getNumberOfFeatures(); for(int i = 0; i < features; i++){ dataFields.add(encodeActiveField(i)); } DataDictionary dataDictionary = new Da...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int getNumberOfFeatures(){ return (Integer)get("rank_"); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public int getNumberOfFeatures(){ int[] shape = getCoefShape(); if(shape.length != 1){ throw new IllegalArgumentException(); } return shape[0]; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public int[] getShape(NDArray array){ Object[] shape = array.getShape(); int[] result = new int[shape.length]; for(int i = 0; i < shape.length; i++){ result[i] = ValueUtil.asInteger((Number)shape[i]); } return result; } ...
#fixed code static public int[] getShape(NDArray array){ Object[] shape = array.getShape(); List<? extends Number> values = (List)Arrays.asList(shape); return Ints.toArray(ValueUtil.asIntegers(values)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void encodeFeatures(SkLearnEncoder encoder){ List<Object[]> steps = getFeatures(); for(int row = 0; row < steps.size(); row++){ Object[] step = steps.get(row); List<String> ids = new ArrayList<>(); List<Feature> features = new ArrayList<>(); List<...
#fixed code public void encodeFeatures(SkLearnEncoder encoder){ Object _default = getDefault(); List<Object[]> rows = getFeatures(); if(!(Boolean.FALSE).equals(_default)){ throw new IllegalArgumentException(); } for(Object[] row : rows){ List<String> ids = new ArrayList<>(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Expression encode(int index, FieldName name){ List<?> classes = getClasses(); Object value = classes.get(index); Number posLabel = getPosLabel(); Number negLabel = getNegLabel(); if(Double.compare(posLabel.doubleValue(), 1d) == 0 && Double.co...
#fixed code @Override public Expression encode(int index, FieldName name){ List<?> classes = getClasses(); Object value = classes.get(index); Number posLabel = getPosLabel(); Number negLabel = getNegLabel(); if(ValueUtil.isOne(posLabel) && ValueUtil.isZero(negLabel)){ NormD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object getMissingValues(){ return asJavaObject(get("missing_values")); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public Object getMissingValues(){ return getScalar("missing_values"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static Expression encodeUFunc(UFunc ufunc, FieldRef fieldRef){ String module = ufunc.getModule(); String name = ufunc.getName(); switch(module){ case "numpy": case "numpy.core.numeric": case "numpy.lib.function_base": break; default: throw new I...
#fixed code static Expression encodeUFunc(UFunc ufunc, FieldRef fieldRef){ String name = ufunc.getName(); switch(name){ case "absolute": return PMMLUtil.createApply("abs", fieldRef); case "ceil": case "exp": case "floor": return PMMLUtil.createApply(name, fieldRef)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static private InputStream init(PushbackInputStream is) throws IOException { byte[] headerBytes = new byte[2 + 19]; ByteStreams.readFully(is, headerBytes); String header = new String(headerBytes); if(!header.startsWith("ZF0x")){ throw new IOException(); } ...
#fixed code static private InputStream init(PushbackInputStream is) throws IOException { byte[] magic = new byte[2]; ByteStreams.readFully(is, magic); is.unread(magic); // Joblib 0.10.0 and newer if(magic[0] == 'x'){ return initZlib(is); } else // Joblib 0.9.4 and earl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int getNumberOfFeatures(){ return (Integer)get("n_features"); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public int getNumberOfFeatures(){ return ValueUtil.asInteger((Number)get("n_features")); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Object loadContent(){ Object[] shape = getShape(); Object descr = getDescr(); byte[] data = (byte[])getData(); try { InputStream is = new ByteArrayInputStream(data); try { return NDArrayUtil.parseData(is, descr, shape); } finally { is.clo...
#fixed code private Object loadContent(){ Object[] shape = getShape(); Object descr = getDescr(); byte[] data = (byte[])getData(); if(descr instanceof DType){ DType dType = (DType)descr; descr = dType.toDescr(); } try { InputStream is = new ByteArrayInputStream(data)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Feature> encodeFeatures(List<String> ids, List<Feature> features, SkLearnEncoder encoder){ List<?> data = getData(); if(ids.size() != 1 || features.size() != 1){ throw new IllegalArgumentException(); } final InvalidValueTreatmentMethod...
#fixed code @Override public List<Feature> encodeFeatures(List<String> ids, List<Feature> features, SkLearnEncoder encoder){ List<?> data = getData(); ClassDictUtil.checkSize(1, ids, features); final InvalidValueTreatmentMethod invalidValueTreatment = DomainUtil.parseInvalidValue...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Number getWeight(int index){ CSRMatrix idfDiag = (CSRMatrix)get("_idf_diag"); List<?> data = idfDiag.getData(); return (Number)data.get(index); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code public Number getWeight(int index){ CSRMatrix idfDiag = get("_idf_diag", CSRMatrix.class); List<?> data = idfDiag.getData(); return (Number)data.get(index); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int getNumberOfFeatures(){ List<?> coefs = getCoefs(); NDArray input = (NDArray)coefs.get(0); int[] shape = NDArrayUtil.getShape(input); return shape[0]; } #location 5 #vulnerability ty...
#fixed code @Override public int getNumberOfFeatures(){ List<? extends HasArray> coefs = getCoefs(); return NeuralNetworkUtil.getNumberOfFeatures(coefs); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Expression encode(int index, FieldName name){ List<?> classes = getClasses(); Object value = classes.get(index); Number posLabel = getPosLabel(); Number negLabel = getNegLabel(); if(Double.compare(posLabel.doubleValue(), 1d) == 0 && Double.co...
#fixed code @Override public Expression encode(int index, FieldName name){ List<?> classes = getClasses(); Object value = classes.get(index); Number posLabel = getPosLabel(); Number negLabel = getNegLabel(); if(ValueUtil.isOne(posLabel) && ValueUtil.isZero(negLabel)){ NormD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public DefineFunction encodeDefineFunction(){ String analyzer = getAnalyzer(); Boolean binary = getBinary(); String stripAccents = getStripAccents(); String tokenPattern = getTokenPattern(); switch(analyzer){ case "word": break; default: throw new ...
#fixed code public DefineFunction encodeDefineFunction(){ String analyzer = getAnalyzer(); Boolean binary = getBinary(); Object preprocessor = getPreprocessor(); String stripAccents = getStripAccents(); Splitter tokenizer = getTokenizer(); switch(analyzer){ case "word": ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ContinuousOutputFeature toContinuousFeature(){ PMMLEncoder encoder = ensureEncoder(); Output output = getOutput(); OutputField outputField = OutputUtil.getOutputField(output, getName()); DataType dataType = outputField.getDataType(); switch(d...
#fixed code @Override public ContinuousOutputFeature toContinuousFeature(){ PMMLEncoder encoder = ensureEncoder(); Output output = getOutput(); OutputField outputField = getField(); DataType dataType = outputField.getDataType(); switch(dataType){ case INTEGER: case FLOAT...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int getNumberOfFeatures(){ return (Integer)get("n_features"); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public int getNumberOfFeatures(){ return ValueUtil.asInteger((Number)get("n_features")); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<?> loadContent(){ DType dtype = getDType(); byte[] obj = getObj(); try { InputStream is = new ByteArrayInputStream(obj); try { return (List<?>)NDArrayUtil.parseData(is, dtype.toDescr(), new Object[0]); } finally { is.close(); } } ...
#fixed code private List<?> loadContent(){ DType dtype = getDType(); byte[] obj = getObj(); try { InputStream is = new ByteArrayInputStream(obj); try { return (List<?>)NDArrayUtil.parseData(is, dtype, new Object[0]); } finally { is.close(); } } catch(IOExceptio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Feature> encodeFeatures(List<String> ids, List<Feature> features, SkLearnEncoder encoder){ List<? extends Number> dataMin = getDataMin(); List<? extends Number> dataMax = getDataMax(); ClassDictUtil.checkSize(ids, features, dataMin, dataMax); ...
#fixed code @Override public List<Feature> encodeFeatures(List<String> ids, List<Feature> features, SkLearnEncoder encoder){ List<? extends Number> dataMin = getDataMin(); List<? extends Number> dataMax = getDataMax(); ClassDictUtil.checkSize(ids, features, dataMin, dataMax); Lis...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Feature> encodeFeatures(List<String> ids, List<Feature> features, SkLearnEncoder encoder){ int[] shape = getComponentsShape(); int numberOfComponents = shape[0]; int numberOfFeatures = shape[1]; if(ids.size() != numberOfFeatures || features...
#fixed code @Override public List<Feature> encodeFeatures(List<String> ids, List<Feature> features, SkLearnEncoder encoder){ int[] shape = getComponentsShape(); int numberOfComponents = shape[0]; int numberOfFeatures = shape[1]; List<? extends Number> components = getComponents()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Feature> encodeFeatures(List<Feature> features, SkLearnEncoder encoder){ String function = translateFunction(getFunction()); if(features.size() <= 1){ return features; } FieldName name = FieldName.create(function + "(" + FeatureUtil.form...
#fixed code @Override public List<Feature> encodeFeatures(List<Feature> features, SkLearnEncoder encoder){ String function = getFunction(); if(features.size() <= 1){ return features; } Apply apply = new Apply(translateFunction(function)); for(Feature feature : features){ ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private int[] getCoefShape(){ NDArrayWrapper arrayWrapper = (NDArrayWrapper)get("coef_"); NDArray array = arrayWrapper.getContent(); return NDArrayUtil.getShape(array); } #location 4 #vulnerability type NUL...
#fixed code private int[] getCoefShape(){ return ClassDictUtil.getShape(this, "coef_"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public List<?> getArray(ClassDict dict, String name, String key){ Object object = unwrap(dict.get(name)); if(object instanceof NDArray){ NDArray array = (NDArray)object; return NDArrayUtil.getContent(array, key); } throw new IllegalArgumentExceptio...
#fixed code static public List<?> getArray(ClassDict dict, String name, String key){ Object object = dict.get(name); if(object instanceof NDArrayWrapper){ NDArrayWrapper arrayWrapper = (NDArrayWrapper)object; object = arrayWrapper.getContent(); } // End if if(object instan...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int getNumberOfFeatures(){ return (Integer)get("n_features_"); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public int getNumberOfFeatures(){ return ValueUtil.asInteger((Number)get("n_features_")); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public List<?> getContent(NDArray array, String key){ Map<String, ?> data = (Map<String, ?>)array.getContent(); return asJavaList(array, (List<?>)data.get(key)); } #location 5 #vulnerability type NULL_...
#fixed code static public List<?> getContent(NDArray array, String key){ Map<String, ?> content = (Map<String, ?>)array.getContent(); return asJavaList(array, (List<?>)content.get(key)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Transformer> getTransformers(){ List<Object[]> steps = getSteps(); boolean flexible = isFlexible(); if(flexible && steps.size() > 0){ Estimator estimator = getEstimator(); if(estimator != null){ steps = steps.subList(0, steps.size() - 1); }...
#fixed code public List<Transformer> getTransformers(){ List<Object[]> steps = getSteps(); return TransformerUtil.asTransformerList(TupleUtil.extractElementList(steps, 1)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Feature> initializeFeatures(SkLearnEncoder encoder){ List<String> featureNames = getFeatureNames(); String separator = getSeparator(); Map<String, Integer> vocabulary = getVocabulary(); Feature[] featureArray = new Feature[featureNames.size(...
#fixed code @Override public List<Feature> initializeFeatures(SkLearnEncoder encoder){ List<? extends String> featureNames = getFeatureNames(); String separator = getSeparator(); Map<String, Integer> vocabulary = getVocabulary(); Feature[] featureArray = new Feature[featureNames.s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public List<?> getArray(ClassDict dict, String name){ Object object = unwrap(dict.get(name)); if(object instanceof NDArray){ NDArray array = (NDArray)object; return NDArrayUtil.getContent(array); } else if(object instanceof CSRMatrix){ CSRMatrix...
#fixed code static public List<?> getArray(ClassDict dict, String name){ Object object = dict.get(name); if(object instanceof HasArray){ HasArray hasArray = (HasArray)object; return hasArray.getArrayContent(); } // End if if(object instanceof Number){ return Collections...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<?> getClasses(){ List<Object> result = new ArrayList<>(); List<?> values = (List<?>)get("classes_"); for(Object value : values){ if(value instanceof HasArray){ HasArray hasArray = (HasArray)value; result.addAll(hasArray.getArrayCo...
#fixed code @Override public List<?> getClasses(){ LabelEncoder labelEncoder = getLabelEncoder(); return labelEncoder.getClasses(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public double[] getValues(){ NDArrayWrapper values = (NDArrayWrapper)get("values"); return Doubles.toArray((List<? extends Number>)values.getContent()); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code public double[] getValues(){ List<? extends Number> values = (List<? extends Number>)ClassDictUtil.getArray(this, "values"); return Doubles.toArray(values); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public MiningModel encodeBooster(HasBooster hasBooster, Schema schema){ Booster booster = hasBooster.getBooster(); Learner learner = booster.getLearner(); Schema xgbSchema = XGBoostUtil.toXGBoostSchema(schema); MiningModel miningModel = learner.encodeMin...
#fixed code static public MiningModel encodeBooster(HasBooster hasBooster, Schema schema){ Booster booster = hasBooster.getBooster(); Learner learner = booster.getLearner(); Schema xgbSchema = XGBoostUtil.toXGBoostSchema(schema); // XXX List<Feature> features = xgbSchema.getFe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<Feature> encodeFeatures(List<Feature> features, SkLearnEncoder encoder){ Object func = getFunc(); UFunc ufunc; try { ufunc = (UFunc)func; } catch(ClassCastException cce){ throw new IllegalArgumentException("The function object (" + Cl...
#fixed code @Override public List<Feature> encodeFeatures(List<Feature> features, SkLearnEncoder encoder){ Object func = getFunc(); if(func == null){ return features; } UFunc ufunc; try { ufunc = (UFunc)func; } catch(ClassCastException cce){ throw new IllegalArgumen...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test_dispatcher_local_greeting_request_completes_before_timeout() { Microservices gateway = Microservices.builder() .services(new GreetingServiceImpl()) .build(); Call service = gateway.call(); Publisher<ServiceMessage> r...
#fixed code @Test public void test_dispatcher_local_greeting_request_completes_before_timeout() { Microservices gateway = Microservices.builder() .discoveryPort(port.incrementAndGet()) .services(new GreetingServiceImpl()) .build(); Call service = gateway...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ServiceMessage decodeMessage(Payload payload) { Builder builder = ServiceMessage.builder(); if (payload.getData().hasRemaining()) { try { builder.data(payload.sliceData()); } catch (Throwable ex) { LOGGER.error("...
#fixed code @Override public ServiceMessage decodeMessage(Payload payload) { Builder builder = ServiceMessage.builder(); if (payload.getData().hasRemaining()) { try { builder.data(payload.sliceData()); } catch (Throwable ex) { LOGGER.error("Failed to ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test_local_quotes_service() throws InterruptedException { Microservices node = Microservices.builder().services(new SimpleQuoteService()).build(); QuoteService service = node.call().api(QuoteService.class); CountDownLatch latch = new Coun...
#fixed code @Test public void test_local_quotes_service() throws InterruptedException { Microservices node = Microservices.builder() .discoveryPort(port.incrementAndGet()) .services(new SimpleQuoteService()).build(); QuoteService service = node.call().api(QuoteSe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ServiceMessage decodeData(ServiceMessage message, Class type) { if (message.data() != null && message.data() instanceof ByteBuf) { ByteBufInputStream inputStream = new ByteBufInputStream(message.data()); try { return ServiceMessa...
#fixed code @Override public ServiceMessage decodeData(ServiceMessage message, Class type) { if (message.data() != null && message.data() instanceof ByteBuf) { try (ByteBufInputStream inputStream = new ByteBufInputStream(message.data(), true)) { return ServiceMessage.fr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void importNodeIndexes(File file, String indexName, String indexType) throws IOException { BatchInserterIndex index; if (indexType.equals("fulltext")) { index = lucene.nodeIndex( indexName, stringMap( "type", "fulltext" ) ); } else { i...
#fixed code private void importNodeIndexes(File file, String indexName, String indexType) throws IOException { BatchInserterIndex index; if (indexType.equals("fulltext")) { index = lucene.nodeIndex( indexName, FULLTEXT_CONFIG ); } else { index = lucene.nodeInde...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void importNodes(File file) throws IOException { BufferedReader bf = new BufferedReader(new FileReader(file)); final Data data = new Data(bf.readLine(), "\t", 0); String line; report.reset(); while ((line = bf.readLine()) ...
#fixed code private void importNodes(File file) throws IOException { BufferedReader bf = new BufferedReader(new FileReader(file)); final Data data = new Data(bf.readLine(), "\t", 0); String line; report.reset(); while ((line = bf.readLine()) != nul...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void importRelationshipIndexes(File file, String indexName, String indexType) throws IOException { BatchInserterIndex index; if (indexType.equals("fulltext")) { index = lucene.relationshipIndex( indexName, stringMap( "type", "fulltext" ) ); ...
#fixed code private void importRelationshipIndexes(File file, String indexName, String indexType) throws IOException { BatchInserterIndex index; if (indexType.equals("fulltext")) { index = lucene.relationshipIndex( indexName, FULLTEXT_CONFIG ); } else { index =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void importRelationships(File file) throws IOException { BufferedReader bf = new BufferedReader(new FileReader(file)); final Data data = new Data(bf.readLine(), "\t", 3); Object[] rel = new Object[3]; final Type type = new Type();...
#fixed code private void importRelationships(File file) throws IOException { BufferedReader bf = new BufferedReader(new FileReader(file)); final Data data = new Data(bf.readLine(), "\t", 3); Object[] rel = new Object[3]; final RelType relType = new RelType...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCache() { long start1 = System.currentTimeMillis(); for (int i = 0; i < size; i++) { userDetailsService.loadUserByUsername("admin"); } long end1 = System.currentTimeMillis(); //关闭缓存 us...
#fixed code @Test public void testCache() { long start1 = System.currentTimeMillis(); int size = 10000; for (int i = 0; i < size; i++) { userDetailsService.loadUserByUsername("admin"); } long end1 = System.currentTimeMillis(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static List<String> readSqlList(File sqlFile) throws Exception { List<String> sqlList = Lists.newArrayList(); StringBuilder sb = new StringBuilder(); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( new FileInpu...
#fixed code private static List<String> readSqlList(File sqlFile) throws Exception { List<String> sqlList = Lists.newArrayList(); StringBuilder sb = new StringBuilder(); try (BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(sqlFile), StandardCh...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test1() { long l = System.currentTimeMillis() / 1000; LocalDateTime localDateTime = DateUtil.fromTimeStamp(l); System.out.printf(DateUtil.localDateTimeFormatyMdHms(localDateTime)); } #locatio...
#fixed code @Test public void test1() { long l = System.currentTimeMillis() / 1000; LocalDateTime localDateTime = DateUtil.fromTimeStamp(l); System.out.print(DateUtil.localDateTimeFormatyMdHms(localDateTime)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void upZipFile(File zipFile, String folderPath) throws ZipException, IOException { File desDir = new File(folderPath); if (!desDir.exists()) { desDir.mkdirs(); } ZipFile zf = new ZipFile(zipFile); for (Enumeration<?> entries = zf.entries(); entri...
#fixed code public static void upZipFile(File zipFile, String folderPath) throws ZipException, IOException { File desDir = new File(folderPath); if (!desDir.exists()) { if (!desDir.mkdirs()) { System.out.println("was not successful."); } } ZipFile zf = new ZipFile(zipFile)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test() public void testSizeControl() throws IOException, InterruptedException, ExecutionException { // very slow running data generator. Don't want to run this normally. To run slow tests use // mvn test -DrunSlowTests=true assumeTrue(Bool...
#fixed code @Test() public void testSizeControl() throws IOException, InterruptedException, ExecutionException { runSizeControl("scaling-avl.tsv", new AvlDigestFactory()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test() public void testSizeControl() throws IOException, InterruptedException, ExecutionException { // very slow running data generator. Don't want to run this normally. To run slow tests use // mvn test -DrunSlowTests=true assumeTrue(Bool...
#fixed code @Test() public void testSizeControl() throws IOException, InterruptedException, ExecutionException { // very slow running data generator. Don't want to run this normally. To run slow tests use // mvn test -DrunSlowTests=true // assumeTrue(Boolean....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static void whitelistVerify( final String remoteHost, final WhitelistItem whitelistItem, final Map<String, List<String>> headers, final String postContent) throws WhitelistException { String whitelistHost = whitelistItem.getHost(); ...
#fixed code static void whitelistVerify( final String remoteHost, final WhitelistItem whitelistItem, final Map<String, List<String>> headers, final String postContent) throws WhitelistException { WhitelistHost whitelistHost = new WhitelistHost(whitelistIt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } Set<? extends Element> compiledJsons = roundEnv.getElementsAnnotatedWith(analysis.compiledJsonElement); Set<? ...
#fixed code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } final DslJson<Object> dslJson = new DslJson<>(Settings.withRuntime().includeServiceLoader()); Set<Type> knownEncoder...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } Set<? extends Element> jsonAnnotated = roundEnv.getElementsAnnotatedWith(jsonTypeElement); if (!jsonAnnotated....
#fixed code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } Set<? extends Element> jsonAnnotated = roundEnv.getElementsAnnotatedWith(jsonTypeElement); if (!jsonAnnotated.isEmpt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver() || annotations.isEmpty()) { return false; } final DslJson<Object> dslJson = new DslJson<>(Settings.withRuntime().includeServiceLoad...
#fixed code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver() || annotations.isEmpty()) { return false; } final DslJson<Object> dslJson = new DslJson<>(Settings.withRuntime().includeServiceLoader(get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } Set<? extends Element> jsonAnnotated = roundEnv.getElementsAnnotatedWith(jsonTypeElement); if (!jsonAnnotated....
#fixed code @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } Set<? extends Element> jsonAnnotated = roundEnv.getElementsAnnotatedWith(jsonTypeElement); if (!jsonAnnotated.isEmpt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @ApiMethod(name = "processSignResponse") public List<String> processSignResponse( @Named("responseData") String responseData, User user) throws OAuthRequestException, ResponseException { if (user == null) { throw new OAuthRequestException("User is ...
#fixed code @ApiMethod(name = "processSignResponse") public List<String> processSignResponse( @Named("responseData") String responseData, User user) throws OAuthRequestException, ResponseException { if (user == null) { throw new OAuthRequestException("User is not au...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @ApiMethod(name = "processRegistrationResponse") public List<String> processRegistrationResponse( @Named("responseData") String responseData, User user) throws OAuthRequestException, ResponseException { if (user == null) { throw new OAuthRequestExc...
#fixed code @ApiMethod(name = "processRegistrationResponse") public List<String> processRegistrationResponse( @Named("responseData") String responseData, User user) throws OAuthRequestException, ResponseException { if (user == null) { throw new OAuthRequestException...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @ApiMethod(name = "processSignResponse") public List<String> processSignResponse( @Named("responseData") String responseData, User user) throws OAuthRequestException, ResponseException { if (user == null) { throw new OAuthRequestException("User is ...
#fixed code @ApiMethod(name = "processSignResponse") public List<String> processSignResponse( @Named("responseData") String responseData, User user) throws OAuthRequestException, ResponseException { if (user == null) { throw new OAuthRequestException("User is not au...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldRunAllQueuedCallbacks() throws Exception { final AtomicInteger count = new AtomicInteger(); final CountDownLatch latch = new CountDownLatch(1000); for(int i = 0; i < 20; i++) { new Thread(new Run...
#fixed code @Test public void shouldRunAllQueuedCallbacks() throws Exception { final int count = 1000; IntFunction<Callable<ResultSet>> insert = value -> () -> dbr.query("INSERT INTO CP_TEST VALUES($1)", singletonList(value)); List<Callable<ResultSet>> tasks =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRoot() throws IOException { CompoundDocument document = createTestDocument(); Entry root = document.getRootEntry(); assertNotNull(root); assertEquals("Root Entry", root.getName()); assertTrue(root.isRoo...
#fixed code @Test public void testRoot() throws IOException { try (CompoundDocument document = createTestDocument()) { Entry root = document.getRootEntry(); assertNotNull(root); assertEquals("Root Entry", root.getName()); asser...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int getHeight() throws IOException { if (compression == 1) { // 1 = no compression Entry height = ifd.getEntryById(TIFF.TAG_IMAGE_HEIGHT); if (height == null) { throw new IIOException("Missing dimensi...
#fixed code @Override public int getHeight() throws IOException { if (compression == 1) { // 1 = no compression Entry height = ifd.getEntryById(TIFF.TAG_IMAGE_HEIGHT); if (height == null) { throw new IIOException("Missing dimensions fo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private DataOutput createCompressorStream(final RenderedImage image, final ImageWriteParam param, final Map<Integer, Entry> entries) { /* 36 MB test data: No compression: Write time: 450 ms output.length: 36000226 PackBi...
#fixed code private DataOutput createCompressorStream(final RenderedImage image, final ImageWriteParam param, final Map<Integer, Entry> entries) { /* 36 MB test data: No compression: Write time: 450 ms output.length: 36000226 PackBits: ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void writeBody(ByteArrayOutputStream pImageData) throws IOException { imageOutput.writeInt(IFF.CHUNK_BODY); imageOutput.writeInt(pImageData.size()); // NOTE: This is much faster than mOutput.write(pImageData.toByteArray()) // as ...
#fixed code private void writeBody(ByteArrayOutputStream pImageData) throws IOException { imageOutput.writeInt(IFF.CHUNK_BODY); imageOutput.writeInt(pImageData.size()); // NOTE: This is much faster than imageOutput.write(pImageData.toByteArray()) // as th...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRoot() throws IOException { CompoundDocument document = createTestDocument(); Entry root = document.getRootEntry(); assertNotNull(root); assertEquals("Root Entry", root.getName()); assertTrue(root.isRoo...
#fixed code @Test public void testRoot() throws IOException { try (CompoundDocument document = createTestDocument()) { Entry root = document.getRootEntry(); assertNotNull(root); assertEquals("Root Entry", root.getName()); asser...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected IIOMetadataNode getStandardChromaNode() { IIOMetadataNode chroma = new IIOMetadataNode("Chroma"); // Handle ColorSpaceType (RGB/CMYK/YCbCr etc)... Entry photometricTag = ifd.getEntryById(TIFF.TAG_PHOTOMETRIC_INTERPRETATIO...
#fixed code @Override protected IIOMetadataNode getStandardChromaNode() { IIOMetadataNode chroma = new IIOMetadataNode("Chroma"); // Handle ColorSpaceType (RGB/CMYK/YCbCr etc)... Entry photometricTag = ifd.getEntryById(TIFF.TAG_PHOTOMETRIC_INTERPRETATION); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEOFExceptionInSegmentParsingShouldNotCreateBadState() throws IOException { ImageInputStream iis = new JPEGSegmentImageInputStream(ImageIO.createImageInputStream(getClassLoaderResource("/broken-jpeg/broken-no-sof-ascii-transfer-mode.jpg"...
#fixed code @Test public void testEOFExceptionInSegmentParsingShouldNotCreateBadState() throws IOException { ImageInputStream iis = new JPEGSegmentImageInputStream(ImageIO.createImageInputStream(getClassLoaderResource("/broken-jpeg/broken-no-sof-ascii-transfer-mode.jpg"))); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadThumbsCatalogFile() throws IOException { CompoundDocument document = createTestDocument(); Entry root = document.getRootEntry(); assertNotNull(root); assertEquals(25, root.getChildEntries().size()); ...
#fixed code @Test public void testReadThumbsCatalogFile() throws IOException { try (CompoundDocument document = createTestDocument()) { Entry root = document.getRootEntry(); assertNotNull(root); assertEquals(25, root.getChildEntries().size...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testContents() throws IOException { CompoundDocument document = createTestDocument(); Entry root = document.getRootEntry(); assertNotNull(root); SortedSet<Entry> children = new TreeSet<Entry>(root.getChildEntries(...
#fixed code @Test public void testContents() throws IOException { try (CompoundDocument document = createTestDocument()) { Entry root = document.getRootEntry(); assertNotNull(root); SortedSet<Entry> children = new TreeSet<Entry>(root.getC...
Below is the vulnerable code, please generate the patch based on the following information.