output stringlengths 79 30.1k | instruction stringclasses 1
value | input stringlengths 216 28.9k |
|---|---|---|
#fixed code
private void incrementalCompile( Set<Object> drivers )
{
for( Object driver: drivers )
{
//noinspection unchecked
Set<IFile> files = ((Collection<File>)ReflectUtil.method( driver, "getResourceFiles" ).invoke() ).stream().map( (File f) -> ManifoldHost.getFi... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void incrementalCompile( Set<Object> drivers )
{
JavacElements elementUtils = JavacElements.instance( _tp.getContext() );
for( Object driver: drivers )
{
//noinspection unchecked
Set<IFile> files = ((Collection<File>)ReflectUtil.method( d... |
#fixed code
@Override
public Collection<String> getAllTypeNames()
{
FqnCache<LocklessLazyVar<M>> fqnCache = _fqnToModel.get();
if( fqnCache.isEmpty() )
{
return Collections.emptySet();
}
return fqnCache.getFqns();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public Collection<String> getAllTypeNames()
{
return _fqnToModel.get().getFqns();
}
#location 4
#vulnerability type NULL_DEREFERENCE |
#fixed code
public Tree getParent( Tree node )
{
return _parents.getParent( node );
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public Tree getParent( Tree node )
{
TreePath2 path = TreePath2.getPath( getCompilationUnit(), node );
if( path == null )
{
// null is indiciative of Generation phase where trees are no longer attached to symobls so the comp unit is detached
// u... |
#fixed code
public ItemList getDataItemList() throws RiotApiException {
return StaticDataMethod.getDataItemList(getRegion(), getKey(), null, null, (ItemListData) null);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public ItemList getDataItemList() throws RiotApiException {
return StaticDataMethod.getDataItemList(getRegion(), getKey(), null, null, null);
}
#location 3
#vulnerability type NULL_DEREFERENCE |
#fixed code
public RiotApiException getException() {
return exception;
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public RiotApiException getException() {
if (!isFailed()) {
return null;
}
return exception;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
protected static CharSequence encodeUriQuery(CharSequence in) {
//Note that I can't simply use URI.java to encode because it will escape pre-existing escaped things.
StringBuilder outBuf = null;
Formatter formatter = null;
for(int i = 0; i < in.length(); i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected static CharSequence encodeUriQuery(CharSequence in) {
//Note that I can't simply use URI.java to encode because it will escape pre-existing escaped things.
StringBuilder outBuf = null;
Formatter formatter = null;
for(int i = 0; i < in.length(); i... |
#fixed code
public static UrlBuilder fromString(final String url, final Charset inputEncoding) {
if (url.isEmpty()) {
return new UrlBuilder();
}
final Matcher m = URI_PATTERN.matcher(url);
String protocol = null, hostName = null, path = null, a... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static UrlBuilder fromString(final String url, final Charset inputEncoding) {
if (url.isEmpty()) {
return new UrlBuilder();
}
final Matcher m = URI_PATTERN.matcher(url);
String protocol = null, hostName = null, path = n... |
#fixed code
public static ClassName get(Class<?> clazz) {
checkNotNull(clazz, "clazz == null");
checkArgument(!clazz.isPrimitive(), "primitive types cannot be represented as a ClassName");
checkArgument(!void.class.equals(clazz), "'void' type cannot be represented as a ClassNam... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static ClassName get(Class<?> clazz) {
checkNotNull(clazz, "clazz == null");
checkArgument(!clazz.isPrimitive(), "primitive types cannot be represented as a ClassName");
checkArgument(!void.class.equals(clazz), "'void' type cannot be represented as a Cl... |
#fixed code
@SuppressWarnings("unchecked")
private static Deserializer deserializer(File file, PoijiOptions options) {
final PoijiStream poiParser = new PoijiStream(file);
final PoiWorkbook workbook = PoiWorkbook.workbook(Files.getExtension(file.getName()), poiParser)... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@SuppressWarnings("unchecked")
private static Deserializer deserializer(File file, PoijiOptions options) throws FileNotFoundException {
final PoijiStream poiParser = new PoijiStream(fileInputStream(file));
final PoiWorkbook workbook = PoiWorkbook.wor... |
#fixed code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk());
FileH... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh... |
#fixed code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk());
FileH... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh... |
#fixed code
@Test
public void bidiBackpressure() throws InterruptedException {
RxNumbersGrpc.RxNumbersStub stub = RxNumbersGrpc.newRxStub(channel);
Flowable<NumberProto.Number> rxRequest = Flowable
.fromIterable(IntStream.range(0, NUMBER_OF_STREAM_ELE... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void bidiBackpressure() throws InterruptedException {
Object lock = new Object();
BackpressureDetector clientReqBPDetector = new BackpressureDetector(madMultipleCutoff);
BackpressureDetector clientRespBPDetector = new Backpressur... |
#fixed code
@Override
public void run() {
final Set<String> artifacts = new HashSet<>();
installNodeModules(artifacts);
final File base = new File(cwd, "node_modules");
final File libs = new File(base, ".lib");
if (force || libs.exists()) {
final double versio... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void run() {
final Set<String> artifacts = new HashSet<>();
installNodeModules(artifacts);
final File base = new File(cwd, "node_modules");
final File libs = new File(base, ".lib");
if (force || libs.exists()) {
final double ... |
#fixed code
@Test
public void agentLoads() throws IOException, InterruptedException {
// If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually.
final String buildDirectory = (String) System.getProperties().get("buildDi... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void agentLoads() throws IOException, InterruptedException {
// If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually.
final String buildDirectory = (String) System.getProperties().get("b... |
#fixed code
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
String[] args = agentArgument.split(":");
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
String[] args = agentArgument.split(":");
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<... |
#fixed code
@Test
public void benchmark() throws InterruptedException {
Benchmark bench = new Benchmark();
// Hipster-Dijkstra
bench.add("Hipster-Dijkstra", new Algorithm() {
AStar<Point> it; Maze2D maze;
public void initialize(Maze2D maz... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void benchmark() throws InterruptedException {
System.out.println("Maze | Hipster-Dijkstra (ms) | JUNG-Dijkstra (ms)");
System.out.println("-------------------------------------------------");
final int times = 5;
for (in... |
#fixed code
@Test
public void testSimpleBookieLedgerMapping() throws Exception {
for (int i = 0; i < numberOfLedgers; i++) {
createAndAddEntriesToLedger().close();
}
BookieLedgerIndexer bookieLedgerIndex = new BookieLedgerIndexer(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testSimpleBookieLedgerMapping() throws Exception {
LedgerManagerFactory newLedgerManagerFactory = LedgerManagerFactory
.newLedgerManagerFactory(baseConf, zkc);
LedgerManager ledgerManager = newLedgerManagerFactory
... |
#fixed code
@Override
public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) {
SyncObj x = (SyncObj) ctx;
if (rc != 0) {
LOG.error("Failure during add {}", rc);
x.failureOccurred = true;
}
sy... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) {
if (rc != 0)
fail("Failed to write entry");
ls = seq;
synchronized (sync) {
sync.value = true;
sync.no... |
#fixed code
protected void callOnError(final ExecutionError error) {
if (onError != null) {
onError.call(error);
}
callOnTerminate((C) error.getContext());
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void callOnError(final ExecutionError error) {
if (onError != null) {
onError.call(error);
}
synchronized (error.getContext()) {
callOnTerminate((C) error.getContext());
error.getContext().notifyAll(... |
#fixed code
protected void callOnFinalState(final State<C> state, final C context) {
try {
if (onFinalStateHandler != null) {
if (isTrace())
log.debug("when final state {} for {} <<<", state, context);
onFinalStateH... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void callOnFinalState(final State<C> state, final C context) {
try {
if (onFinalStateHandler != null) {
if (isTrace())
log.debug("when final state {} for {} <<<", state, context);
onFinal... |
#fixed code
public void startDb() {
postgres = new MyPostgreSQLContainer()
.withDatabaseName(TEST_SCHEMA_NAME)
.withUsername("SA")
.withPassword("pass")
.withLogConsumer(new Consumer<OutputFrame>() {
@Override
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void startDb() {
postgres = (PostgreSQLContainer) new PostgreSQLContainer()
.withDatabaseName(TEST_SCHEMA_NAME)
.withUsername("SA")
.withPassword("pass")
.withLogConsumer(new Consumer<OutputFrame>() {
... |
#fixed code
@Override
public void run()
{
while (this.running)
{
//input
while (!this.inputs.isEmpty())
{
DatagramPacket dp = this.inputs.remove();
KcpOnUdp ku = this.kcps.get(dp.sender());
if (ku == null)
{
ku = new K... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void run()
{
while (this.running)
{
//input
while (!this.inputs.isEmpty())
{
DatagramPacket dp = this.inputs.remove();
KcpOnUdp ku = this.kcps.get(dp.sender());
if (ku == null)
{
ku =... |
#fixed code
public static Instances createBootstrapSample(Instances instances) {
Random rand = Random.getInstance();
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < instances.size(); i++) {
int idx = rand.nextInt(instances.size());
map.put(idx, map.getOrDefault(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static Instances createBootstrapSample(Instances instances) {
Random rand = Random.getInstance();
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < instances.size(); i++) {
int idx = rand.nextInt(instances.size());
if (!map.containsKey(idx... |
#fixed code
public void commit(Transaction transaction) throws RollbackException, TransactionException {
if (LOG.isTraceEnabled()) {
LOG.trace("commit " + transaction);
}
if (transaction.getStatus() != Status.RUNNING) {
throw new IllegalArg... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void commit(Transaction transaction) throws RollbackException, TransactionException {
if (LOG.isTraceEnabled()) {
LOG.trace("commit " + transaction);
}
// Check rollbackOnly status
if (transaction.isRollbackOnly()) {
... |
#fixed code
@Test
public void runTestWriteWriteConflict() throws Exception {
TransactionManager tm = new TransactionManager(hbaseConf);
TTable tt = new TTable(hbaseConf, TEST_TABLE);
TransactionState t1 = tm.beginTransaction();
LOG.info("Transaction created " +... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void runTestWriteWriteConflict() throws Exception {
TransactionManager tm = new TransactionManager(hbaseConf);
TransactionalTable tt = new TransactionalTable(hbaseConf, TEST_TABLE);
TransactionState t1 = tm.beginTransaction();
LOG... |
#fixed code
@Test(timeOut = 30_000)
public void runTestInterleaveScanWhenATransactionAborts() throws Exception {
TransactionManager tm = newTransactionManager();
TTable tt = new TTable(hbaseConf, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.info("Tr... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test(timeOut = 30_000)
public void runTestInterleaveScanWhenATransactionAborts() throws Exception {
TransactionManager tm = newTransactionManager();
TTable tt = new TTable(hbaseConf, TEST_TABLE);
Transaction t1 = tm.begin();
LOG.in... |
#fixed code
public byte[] getChannelConfigurationBytes() throws TransactionException {
try {
final Block configBlock = getConfigBlock(getRandomPeer());
Envelope envelopeRet = Envelope.parseFrom(configBlock.getData().getData(0));
Payload paylo... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public byte[] getChannelConfigurationBytes() throws TransactionException {
try {
final Block configBlock = getConfigurationBlock();
Envelope envelopeRet = Envelope.parseFrom(configBlock.getData().getData(0));
Payload payload... |
#fixed code
Orderer(String name, String url, Properties properties) throws InvalidArgumentException {
if (StringUtil.isNullOrEmpty(name)) {
throw new InvalidArgumentException("Invalid name for orderer");
}
Exception e = checkGrpcUrl(url);
if (... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
DeliverResponse[] sendDeliver(Common.Envelope transaction) throws TransactionException {
if (shutdown) {
throw new TransactionException(format("Orderer %s was shutdown.", name));
}
OrdererClient localOrdererClient = ordererClient;
... |
#fixed code
@Test
public void testGetInfo() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
HFCAInfo info = client.info();
assertNull(info.getVersion());
}
if (!testConfig.isRunningAgainstFabric10()) {
HFCA... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testGetInfo() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
HFCAInfo info = client.info();
assertNull(info.getVersion());
}
if (!testConfig.isRunningAgainstFabric10()) {
... |
#fixed code
boolean hasConnected() {
return connected;
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void setProperties(Properties properties) {
this.properties = properties;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
private static final Collection<MapArea> createAreasForSimpleMultipolygon(OsmRelation relation,
TLongObjectMap<MapNode> nodeIdMap, OsmEntityProvider db) throws EntityNotFoundException {
assert isSimpleMultipolygon(relation, db);
OsmEntity tagSource = null;
List<MapNod... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static final Collection<MapArea> createAreasForSimpleMultipolygon(OsmRelation relation,
TLongObjectMap<MapNode> nodeIdMap, OsmEntityProvider db) throws EntityNotFoundException {
assert isSimpleMultipolygon(relation, db);
OsmEntity tagSource = null;
List<... |
#fixed code
public static final boolean isJOSMGenerated(File file) {
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
for (int i=0; i<100; i++) {
String line = reader.readLine();
if (line != null) {
if (line.contains("generator='JOSM'")... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static final boolean isJOSMGenerated(File file) {
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
for (int i=0; i<100; i++) {
String line = reader.readLine();
if (line != null) {
if (line.contains("generator='J... |
#fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... |
#fixed code
@Test
public void finishSpan() {
Span finished = new Span().setName("foo").setTimestamp(1000L); // set in start span
finished.startTick = 500000L; // set in start span
state.setCurrentLocalSpan(finished);
PowerMockito.when(System.nanoTime(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void finishSpan() {
Span finished = new Span().setTimestamp(1000L); // set in start span
finished.startTick = 500000L; // set in start span
state.setCurrentLocalSpan(finished);
PowerMockito.when(System.nanoTime()).thenRe... |
#fixed code
@Override
protected void reloadPage() {
synchronized (this) {
selectedSort = null;
sortFieldLeft = null;
super.reloadPage();
}
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
protected void reloadPage() {
selectedSort = null;
sortFieldLeft = null;
super.reloadPage();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
public void getStartingWith(String queryString, Field field, String start,
int limit, List<NamedItem> list) throws ParseException,
IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException, SearchLibException,
InstantiationException, ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void getStartingWith(String queryString, Field field, String start,
int limit, List<NamedItem> list) throws ParseException,
IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException, SearchLibException,
InstantiationExcep... |
#fixed code
@Override
public String visitQuery_specification(VerdictSQLParser.Query_specificationContext ctx) {
StringBuilder sql = new StringBuilder(2000);
// this statement computes the mean value
AnalyticSelectStatementRewriter meanRewriter = new AnalyticSelectStatementRewriter... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public String visitQuery_specification(VerdictSQLParser.Query_specificationContext ctx) {
List<Pair<String, String>> subqueryColName2Aliases = null;
BootstrapSelectStatementRewriter singleRewriter = null;
StringBuilder unionedFrom = new StringBuilder(20... |
#fixed code
private boolean stopUsingMysqldadmin() {
boolean retValue = false;
Reader stdOut = null;
Reader stdErr = null;
LogFileProcessor processor = null;
Set<String> successPatterns = Sets.newHashSet(
"'Can't connect to MySQL s... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private boolean stopUsingMysqldadmin() {
boolean retValue = false;
Reader stdOut = null;
Reader stdErr = null;
LogFileProcessor processor = null;
Set<String> successPatterns = Sets.newHashSet("'Can't connect to MySQL server on 'l... |
#fixed code
public <T> MappingIterator<T> readValues(File src)
throws IOException, JsonProcessingException
{
if (_dataFormatReaders != null) {
return _detectBindAndReadValues(
_dataFormatReaders.findFormat(_inputStream(src)), false);
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public <T> MappingIterator<T> readValues(File src)
throws IOException, JsonProcessingException
{
if (_dataFormatReaders != null) {
return _detectBindAndReadValues(
_dataFormatReaders.findFormat(_inputStream(src)), fals... |
#fixed code
@Override
public String idFromValue(Object value)
{
return idFromClass(value.getClass());
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public String idFromValue(Object value)
{
Class<?> cls = _typeFactory.constructType(value.getClass()).getRawClass();
final String key = cls.getName();
String name;
synchronized (_typeToId) {
name = _typeToId.... |
#fixed code
public void testAtomicInt() throws Exception
{
AtomicInteger value = MAPPER.readValue("13", AtomicInteger.class);
assertEquals(13, value.get());
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void testAtomicInt() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
AtomicInteger value = mapper.readValue("13", AtomicInteger.class);
assertEquals(13, value.get());
}
#location 5
... |
#fixed code
@Test
public void testVideosSitemap() throws UnknownFormatException, IOException {
SiteMapParser parser = new SiteMapParser();
parser.enableExtension(Extension.VIDEO);
String contentType = "text/xml";
byte[] content = SiteMapParserTest.get... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testVideosSitemap() throws UnknownFormatException, IOException {
SiteMapParser parser = new SiteMapParser();
parser.enableExtension(Extension.VIDEO);
String contentType = "text/xml";
byte[] content = SiteMapParserTe... |
#fixed code
@Test
public void moderator_should_approve_question_information() throws Exception {
Information approvedInfo = new QuestionInformation("edited title", "edited desc",
new LoggedUser(otherUser, null), new ArrayList<Tag>(), "comment");
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void moderator_should_approve_question_information() throws Exception {
Question question = question("question title", "question description", author);
Information approvedInfo = new QuestionInformation("edited title", "edited desc",
... |
#fixed code
@Override
public SyndFeedInfo remove(final URL url) {
SyndFeedInfo info = null;
final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim();
FileInputStream fis = null;
ObjectInputStream... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public SyndFeedInfo remove(final URL url) {
SyndFeedInfo info = null;
final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim();
FileInputStream fis;
try {
... |
#fixed code
public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
final InputStream is;
if (prologEnc == null) {
is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc);
} else ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
final InputStream is;
if (prologEnc == null) {
is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc);
}... |
#fixed code
protected void testRawBomValid(final String encoding) throws Exception {
final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding);
final XmlReader xmlReader = new XmlReader(is, false);
if (!encoding.equals("UTF-16")) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void testRawBomValid(final String encoding) throws Exception {
final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding);
final XmlReader xmlReader = new XmlReader(is, false);
if (!encoding.equals("UTF-16")) {
... |
#fixed code
static String load(File in, String charsetName) throws IOException {
InputStream inStream = new FileInputStream(in);
String data = readInputStream(inStream, charsetName);
inStream.close();
return data;
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
static String load(File in, String charsetName) throws IOException {
char[] buffer = new char[0x20000]; // ~ 130K
StringBuilder data = new StringBuilder(0x20000);
InputStream inStream = new FileInputStream(in);
Reader inReader = n... |
#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
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
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
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
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 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
@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
@SuppressWarnings({"unchecked", "rawtypes"})
public void onReceive(ServiceContext serviceContext) throws Throwable {
FlowMessage fm = serviceContext.getFlowMessage();
if (serviceContext.isSync() && !syncActors.containsKey(serviceContext.getId())) {
syncAct... |
#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
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
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 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 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 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 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 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
public void setSqlSource(MappedStatement ms) {
MapperTemplate mapperTemplate = getMapperTemplate(ms.getId());
try {
if (mapperTemplate != null) {
mapperTemplate.setSqlSource(ms);
}
} catch (Exception e) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void setSqlSource(MappedStatement ms) {
MapperTemplate mapperTemplate = getMapperTemplate(ms.getId());
try {
mapperTemplate.setSqlSource(ms);
} catch (Exception e) {
throw new RuntimeException("调用方法异常:" + e.getMessa... |
#fixed code
public boolean isIterableMapping() {
return getSingleSourceParameter().getType().isIterableType() && getResultType().isIterableType();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public boolean isIterableMapping() {
return getSingleSourceType().isIterableType() && resultType.isIterableType();
}
#location 2
#vulnerability type NULL_DEREFERENCE |
#fixed code
private List<Method> retrieveMethods(TypeElement element, boolean implementationRequired) {
List<Method> methods = new ArrayList<Method>();
MapperPrism mapperPrism = implementationRequired ? MapperPrism.getInstanceOn( element ) : null;
for ( Executab... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private List<Method> retrieveMethods(TypeElement element, boolean implementationRequired) {
List<Method> methods = new ArrayList<Method>();
MapperPrism mapperPrism = implementationRequired ? MapperPrism.getInstanceOn( element ) : null;
//TODO E... |
#fixed code
public boolean matches() {
// check & collect generic types.
List<? extends VariableElement> candidateParameters = candidateMethod.getExecutable().getParameters();
if ( candidateParameters.size() != 1 ) {
typesMatch = false;
}
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public boolean matches() {
// check & collect generic types.
List<? extends VariableElement> candidateParameters = candidateMethod.getExecutable().getParameters();
if ( candidateParameters.size() == parameters.length ) {
for ( int i ... |
#fixed code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
case V8Va... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
cas... |
#fixed code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
releaseResources();
shutdownExecutors(forceTerminateExecutors);
if (executors != null) {
executors.clear... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
if (debugEnabled) {
disableDebugSupport();
}
releaseResources();
shutdownExecutors(forceTe... |
#fixed code
@Test
public void testTypedArrayGetValue_Float64Array() {
V8Array floatsArray = v8.executeArrayScript("var buf = new ArrayBuffer(80);\n"
+ "var floatsArray = new Float64Array(buf);\n"
+ "floatsArray[0] = 16.2;\n"
+ "... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testTypedArrayGetValue_Float64Array() {
V8Array floatsArray = v8.executeArrayScript("var buf = new ArrayBuffer(80);\n"
+ "var floatsArray = new Float64Array(buf);\n"
+ "floatsArray[0] = 16.2;\n"
... |
#fixed code
@Test
public void testPartialResults() throws Exception {
byte[] key1 = randomBytes(8);
byte[] key2 = randomBytes(8);
FlatRow response1 =
FlatRow.newBuilder()
.withRowKey(ByteString.copyFrom(key1))
.addCell(
new Cell... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testPartialResults() throws Exception {
byte[] key1 = randomBytes(8);
byte[] key2 = randomBytes(8);
FlatRow response1 =
FlatRow.newBuilder()
.withRowKey(ByteString.copyFrom(key1))
.addCell(
ne... |
#fixed code
public void awaitCompletion() throws InterruptedException {
boolean performedWarning = false;
lock.lock();
try {
while (!isFlushed()) {
flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS);
long now = clock.nanoTime();
if (... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void awaitCompletion() throws InterruptedException {
boolean performedWarning = false;
lock.lock();
try {
while (!isFlushed()) {
flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS);
long now = clock.nanoTime();
... |
#fixed code
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
// restart the clock.
synchronized (callLock) {
super.run();
// pre-fetch one more result, for performance reasons.
adapter.request(1);
if (rowObserver instanc... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
// restart the clock.
this.rowMerger = new RowMerger(rowObserver);
adapter = new CallToStreamObserverAdapter();
synchronized (callLock) {
super.run();
// pre... |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 4