project
stringclasses 791
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 127
values | func
stringlengths 5
484k
| vul
int8 0
1
|
---|---|---|---|---|---|
postgresql | 08fa47c4850cea32c3116665975bca219fbf2fe6 | NOT_APPLICABLE | NOT_APPLICABLE | extract_mb_char(char *s)
{
char *res;
int len;
len = pg_mblen(s);
res = palloc(len + 1);
memcpy(res, s, len);
res[len] = '\0';
return res;
}
| 0 |
chrony | 7712455d9aa33d0db0945effaa07e900b85987b1 | NOT_APPLICABLE | NOT_APPLICABLE | read_mask_address(char *line, IPAddr *mask, IPAddr *address)
{
unsigned int bits;
char *p, *q;
p = line;
if (!*p) {
mask->family = address->family = IPADDR_UNSPEC;
return 1;
} else {
q = strchr(p, '/');
if (q) {
*q++ = 0;
if (UTI_StringToIP(p, mask)) {
p = q;
if (UTI_StringToIP(p, address)) {
if (address->family == mask->family)
return 1;
} else if (sscanf(p, "%u", &bits) == 1) {
*address = *mask;
bits_to_mask(bits, address->family, mask);
return 1;
}
}
} else {
if (DNS_Name2IPAddress(p, address) == DNS_Success) {
bits_to_mask(-1, address->family, mask);
return 1;
} else {
fprintf(stderr, "Could not get address for hostname\n");
return 0;
}
}
}
fprintf(stderr, "Invalid syntax for mask/address\n");
return 0;
} | 0 |
php | 0e6fe3a4c96be2d3e88389a5776f878021b4c59f | NOT_APPLICABLE | NOT_APPLICABLE | ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC) /* {{{ */
{
const zend_function_entry *ptr = functions;
int i=0;
HashTable *target_function_table = function_table;
if (!target_function_table) {
target_function_table = CG(function_table);
}
while (ptr->fname) {
if (count!=-1 && i>=count) {
break;
}
#if 0
zend_printf("Unregistering %s()\n", ptr->fname);
#endif
zend_hash_del(target_function_table, ptr->fname, strlen(ptr->fname)+1);
ptr++;
i++;
}
}
/* }}} */
| 0 |
linux | 9f46c187e2e680ecd9de7983e4d081c3391acc76 | NOT_APPLICABLE | NOT_APPLICABLE | static void mmu_free_root_page(struct kvm *kvm, hpa_t *root_hpa,
struct list_head *invalid_list)
{
struct kvm_mmu_page *sp;
if (!VALID_PAGE(*root_hpa))
return;
sp = to_shadow_page(*root_hpa & PT64_BASE_ADDR_MASK);
if (WARN_ON(!sp))
return;
if (is_tdp_mmu_page(sp))
kvm_tdp_mmu_put_root(kvm, sp, false);
else if (!--sp->root_count && sp->role.invalid)
kvm_mmu_prepare_zap_page(kvm, sp, invalid_list);
*root_hpa = INVALID_PAGE;
} | 0 |
linux | 22f6b4d34fcf039c63a94e7670e0da24f8575a5a | NOT_APPLICABLE | NOT_APPLICABLE | static int aio_setup_ring(struct kioctx *ctx)
{
struct aio_ring *ring;
unsigned nr_events = ctx->max_reqs;
struct mm_struct *mm = current->mm;
unsigned long size, unused;
int nr_pages;
int i;
struct file *file;
/* Compensate for the ring buffer's head/tail overlap entry */
nr_events += 2; /* 1 is required, 2 for good luck */
size = sizeof(struct aio_ring);
size += sizeof(struct io_event) * nr_events;
nr_pages = PFN_UP(size);
if (nr_pages < 0)
return -EINVAL;
file = aio_private_file(ctx, nr_pages);
if (IS_ERR(file)) {
ctx->aio_ring_file = NULL;
return -ENOMEM;
}
ctx->aio_ring_file = file;
nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring))
/ sizeof(struct io_event);
ctx->ring_pages = ctx->internal_pages;
if (nr_pages > AIO_RING_PAGES) {
ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
GFP_KERNEL);
if (!ctx->ring_pages) {
put_aio_ring_file(ctx);
return -ENOMEM;
}
}
for (i = 0; i < nr_pages; i++) {
struct page *page;
page = find_or_create_page(file->f_inode->i_mapping,
i, GFP_HIGHUSER | __GFP_ZERO);
if (!page)
break;
pr_debug("pid(%d) page[%d]->count=%d\n",
current->pid, i, page_count(page));
SetPageUptodate(page);
unlock_page(page);
ctx->ring_pages[i] = page;
}
ctx->nr_pages = i;
if (unlikely(i != nr_pages)) {
aio_free_ring(ctx);
return -ENOMEM;
}
ctx->mmap_size = nr_pages * PAGE_SIZE;
pr_debug("attempting mmap of %lu bytes\n", ctx->mmap_size);
if (down_write_killable(&mm->mmap_sem)) {
ctx->mmap_size = 0;
aio_free_ring(ctx);
return -EINTR;
}
ctx->mmap_base = do_mmap_pgoff(ctx->aio_ring_file, 0, ctx->mmap_size,
PROT_READ | PROT_WRITE,
MAP_SHARED, 0, &unused);
up_write(&mm->mmap_sem);
if (IS_ERR((void *)ctx->mmap_base)) {
ctx->mmap_size = 0;
aio_free_ring(ctx);
return -ENOMEM;
}
pr_debug("mmap address: 0x%08lx\n", ctx->mmap_base);
ctx->user_id = ctx->mmap_base;
ctx->nr_events = nr_events; /* trusted copy */
ring = kmap_atomic(ctx->ring_pages[0]);
ring->nr = nr_events; /* user copy */
ring->id = ~0U;
ring->head = ring->tail = 0;
ring->magic = AIO_RING_MAGIC;
ring->compat_features = AIO_RING_COMPAT_FEATURES;
ring->incompat_features = AIO_RING_INCOMPAT_FEATURES;
ring->header_length = sizeof(struct aio_ring);
kunmap_atomic(ring);
flush_dcache_page(ctx->ring_pages[0]);
return 0;
}
| 0 |
linux | a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e | NOT_APPLICABLE | NOT_APPLICABLE | */
struct net_device *of_find_net_device_by_node(struct device_node *np)
{
struct device *dev;
dev = class_find_device(&net_class, NULL, np, of_dev_node_match);
if (!dev)
return NULL;
return to_net_dev(dev); | 0 |
linux | b348d7dddb6c4fbfc810b7a0626e8ec9e29f7cbb | NOT_APPLICABLE | NOT_APPLICABLE | static void usbip_pack_ret_submit(struct usbip_header *pdu, struct urb *urb,
int pack)
{
struct usbip_header_ret_submit *rpdu = &pdu->u.ret_submit;
if (pack) {
rpdu->status = urb->status;
rpdu->actual_length = urb->actual_length;
rpdu->start_frame = urb->start_frame;
rpdu->number_of_packets = urb->number_of_packets;
rpdu->error_count = urb->error_count;
} else {
urb->status = rpdu->status;
urb->actual_length = rpdu->actual_length;
urb->start_frame = rpdu->start_frame;
urb->number_of_packets = rpdu->number_of_packets;
urb->error_count = rpdu->error_count;
}
}
| 0 |
Chrome | 04915c26ea193247b8a29aa24bfa34578ef5d39e | NOT_APPLICABLE | NOT_APPLICABLE | QRectF GraphicsContext3DPrivate::boundingRect() const
{
return QRectF(QPointF(0, 0), QSizeF(m_context->m_currentWidth, m_context->m_currentHeight));
}
| 0 |
linux | b6878d9e03043695dbf3fa1caa6dfc09db225b16 | NOT_APPLICABLE | NOT_APPLICABLE | static int set_bitmap_file(struct mddev *mddev, int fd)
{
int err = 0;
if (mddev->pers) {
if (!mddev->pers->quiesce || !mddev->thread)
return -EBUSY;
if (mddev->recovery || mddev->sync_thread)
return -EBUSY;
/* we should be able to change the bitmap.. */
}
if (fd >= 0) {
struct inode *inode;
struct file *f;
if (mddev->bitmap || mddev->bitmap_info.file)
return -EEXIST; /* cannot add when bitmap is present */
f = fget(fd);
if (f == NULL) {
printk(KERN_ERR "%s: error: failed to get bitmap file\n",
mdname(mddev));
return -EBADF;
}
inode = f->f_mapping->host;
if (!S_ISREG(inode->i_mode)) {
printk(KERN_ERR "%s: error: bitmap file must be a regular file\n",
mdname(mddev));
err = -EBADF;
} else if (!(f->f_mode & FMODE_WRITE)) {
printk(KERN_ERR "%s: error: bitmap file must open for write\n",
mdname(mddev));
err = -EBADF;
} else if (atomic_read(&inode->i_writecount) != 1) {
printk(KERN_ERR "%s: error: bitmap file is already in use\n",
mdname(mddev));
err = -EBUSY;
}
if (err) {
fput(f);
return err;
}
mddev->bitmap_info.file = f;
mddev->bitmap_info.offset = 0; /* file overrides offset */
} else if (mddev->bitmap == NULL)
return -ENOENT; /* cannot remove what isn't there */
err = 0;
if (mddev->pers) {
mddev->pers->quiesce(mddev, 1);
if (fd >= 0) {
struct bitmap *bitmap;
bitmap = bitmap_create(mddev, -1);
if (!IS_ERR(bitmap)) {
mddev->bitmap = bitmap;
err = bitmap_load(mddev);
} else
err = PTR_ERR(bitmap);
}
if (fd < 0 || err) {
bitmap_destroy(mddev);
fd = -1; /* make sure to put the file */
}
mddev->pers->quiesce(mddev, 0);
}
if (fd < 0) {
struct file *f = mddev->bitmap_info.file;
if (f) {
spin_lock(&mddev->lock);
mddev->bitmap_info.file = NULL;
spin_unlock(&mddev->lock);
fput(f);
}
}
return err;
}
| 0 |
Chrome | 6a310d99a741f9ba5e4e537c5ec49d3adbe5876f | NOT_APPLICABLE | NOT_APPLICABLE | void AXTree::UpdateData(const AXTreeData& new_data) {
if (data_ == new_data)
return;
AXTreeData old_data = data_;
data_ = new_data;
for (AXTreeObserver& observer : observers_)
observer.OnTreeDataChanged(this, old_data, new_data);
}
| 0 |
Chrome | c13e1da62b5f5f0e6fe8c1f769a5a28415415244 | NOT_APPLICABLE | NOT_APPLICABLE | void GLES2DecoderImpl::DoTexParameterf(
GLenum target, GLenum pname, GLfloat param) {
TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
if (!info) {
SetGLError(GL_INVALID_VALUE, "glTexParameterf: unknown texture");
return;
}
if (!texture_manager()->SetParameter(
feature_info_, info, pname, static_cast<GLint>(param))) {
SetGLError(GL_INVALID_ENUM, "glTexParameterf: param GL_INVALID_ENUM");
return;
}
glTexParameterf(target, pname, param);
}
| 0 |
linux | 6caabe7f197d3466d238f70915d65301f1716626 | NOT_APPLICABLE | NOT_APPLICABLE | static int hsr_dev_close(struct net_device *dev)
{
/* Nothing to do here. */
return 0;
}
| 0 |
Chrome | 04aaacb936a08d70862d6d9d7e8354721ae46be8 | NOT_APPLICABLE | NOT_APPLICABLE | bool AppCacheDatabase::FindOriginsWithGroups(std::set<url::Origin>* origins) {
DCHECK(origins && origins->empty());
if (!LazyOpen(kDontCreate))
return false;
static const char kSql[] = "SELECT DISTINCT(origin) FROM Groups";
sql::Statement statement(db_->GetUniqueStatement(kSql));
while (statement.Step())
origins->insert(url::Origin::Create(GURL(statement.ColumnString(0))));
return statement.Succeeded();
}
| 0 |
net | 3cf2b61eb06765e27fec6799292d9fb46d0b7e60 | NOT_APPLICABLE | NOT_APPLICABLE | int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr)
{
u64 start_time = ktime_get_ns();
struct bpf_verifier_env *env;
struct bpf_verifier_log *log;
int i, len, ret = -EINVAL;
bool is_priv;
/* no program is valid */
if (ARRAY_SIZE(bpf_verifier_ops) == 0)
return -EINVAL;
/* 'struct bpf_verifier_env' can be global, but since it's not small,
* allocate/free it every time bpf_check() is called
*/
env = kzalloc(sizeof(struct bpf_verifier_env), GFP_KERNEL);
if (!env)
return -ENOMEM;
log = &env->log;
len = (*prog)->len;
env->insn_aux_data =
vzalloc(array_size(sizeof(struct bpf_insn_aux_data), len));
ret = -ENOMEM;
if (!env->insn_aux_data)
goto err_free_env;
for (i = 0; i < len; i++)
env->insn_aux_data[i].orig_idx = i;
env->prog = *prog;
env->ops = bpf_verifier_ops[env->prog->type];
env->fd_array = make_bpfptr(attr->fd_array, uattr.is_kernel);
is_priv = bpf_capable();
bpf_get_btf_vmlinux();
/* grab the mutex to protect few globals used by verifier */
if (!is_priv)
mutex_lock(&bpf_verifier_lock);
if (attr->log_level || attr->log_buf || attr->log_size) {
/* user requested verbose verifier output
* and supplied buffer to store the verification trace
*/
log->level = attr->log_level;
log->ubuf = (char __user *) (unsigned long) attr->log_buf;
log->len_total = attr->log_size;
ret = -EINVAL;
/* log attributes have to be sane */
if (log->len_total < 128 || log->len_total > UINT_MAX >> 2 ||
!log->level || !log->ubuf || log->level & ~BPF_LOG_MASK)
goto err_unlock;
}
if (IS_ERR(btf_vmlinux)) {
/* Either gcc or pahole or kernel are broken. */
verbose(env, "in-kernel BTF is malformed\n");
ret = PTR_ERR(btf_vmlinux);
goto skip_full_check;
}
env->strict_alignment = !!(attr->prog_flags & BPF_F_STRICT_ALIGNMENT);
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
env->strict_alignment = true;
if (attr->prog_flags & BPF_F_ANY_ALIGNMENT)
env->strict_alignment = false;
env->allow_ptr_leaks = bpf_allow_ptr_leaks();
env->allow_uninit_stack = bpf_allow_uninit_stack();
env->allow_ptr_to_map_access = bpf_allow_ptr_to_map_access();
env->bypass_spec_v1 = bpf_bypass_spec_v1();
env->bypass_spec_v4 = bpf_bypass_spec_v4();
env->bpf_capable = bpf_capable();
if (is_priv)
env->test_state_freq = attr->prog_flags & BPF_F_TEST_STATE_FREQ;
env->explored_states = kvcalloc(state_htab_size(env),
sizeof(struct bpf_verifier_state_list *),
GFP_USER);
ret = -ENOMEM;
if (!env->explored_states)
goto skip_full_check;
ret = add_subprog_and_kfunc(env);
if (ret < 0)
goto skip_full_check;
ret = check_subprogs(env);
if (ret < 0)
goto skip_full_check;
ret = check_btf_info(env, attr, uattr);
if (ret < 0)
goto skip_full_check;
ret = check_attach_btf_id(env);
if (ret)
goto skip_full_check;
ret = resolve_pseudo_ldimm64(env);
if (ret < 0)
goto skip_full_check;
if (bpf_prog_is_dev_bound(env->prog->aux)) {
ret = bpf_prog_offload_verifier_prep(env->prog);
if (ret)
goto skip_full_check;
}
ret = check_cfg(env);
if (ret < 0)
goto skip_full_check;
ret = do_check_subprogs(env);
ret = ret ?: do_check_main(env);
if (ret == 0 && bpf_prog_is_dev_bound(env->prog->aux))
ret = bpf_prog_offload_finalize(env);
skip_full_check:
kvfree(env->explored_states);
if (ret == 0)
ret = check_max_stack_depth(env);
/* instruction rewrites happen after this point */
if (is_priv) {
if (ret == 0)
opt_hard_wire_dead_code_branches(env);
if (ret == 0)
ret = opt_remove_dead_code(env);
if (ret == 0)
ret = opt_remove_nops(env);
} else {
if (ret == 0)
sanitize_dead_code(env);
}
if (ret == 0)
/* program is valid, convert *(u32*)(ctx + off) accesses */
ret = convert_ctx_accesses(env);
if (ret == 0)
ret = do_misc_fixups(env);
/* do 32-bit optimization after insn patching has done so those patched
* insns could be handled correctly.
*/
if (ret == 0 && !bpf_prog_is_dev_bound(env->prog->aux)) {
ret = opt_subreg_zext_lo32_rnd_hi32(env, attr);
env->prog->aux->verifier_zext = bpf_jit_needs_zext() ? !ret
: false;
}
if (ret == 0)
ret = fixup_call_args(env);
env->verification_time = ktime_get_ns() - start_time;
print_verification_stats(env);
env->prog->aux->verified_insns = env->insn_processed;
if (log->level && bpf_verifier_log_full(log))
ret = -ENOSPC;
if (log->level && !log->ubuf) {
ret = -EFAULT;
goto err_release_maps;
}
if (ret)
goto err_release_maps;
if (env->used_map_cnt) {
/* if program passed verifier, update used_maps in bpf_prog_info */
env->prog->aux->used_maps = kmalloc_array(env->used_map_cnt,
sizeof(env->used_maps[0]),
GFP_KERNEL);
if (!env->prog->aux->used_maps) {
ret = -ENOMEM;
goto err_release_maps;
}
memcpy(env->prog->aux->used_maps, env->used_maps,
sizeof(env->used_maps[0]) * env->used_map_cnt);
env->prog->aux->used_map_cnt = env->used_map_cnt;
}
if (env->used_btf_cnt) {
/* if program passed verifier, update used_btfs in bpf_prog_aux */
env->prog->aux->used_btfs = kmalloc_array(env->used_btf_cnt,
sizeof(env->used_btfs[0]),
GFP_KERNEL);
if (!env->prog->aux->used_btfs) {
ret = -ENOMEM;
goto err_release_maps;
}
memcpy(env->prog->aux->used_btfs, env->used_btfs,
sizeof(env->used_btfs[0]) * env->used_btf_cnt);
env->prog->aux->used_btf_cnt = env->used_btf_cnt;
}
if (env->used_map_cnt || env->used_btf_cnt) {
/* program is valid. Convert pseudo bpf_ld_imm64 into generic
* bpf_ld_imm64 instructions
*/
convert_pseudo_ld_imm64(env);
}
adjust_btf_func(env);
err_release_maps:
if (!env->prog->aux->used_maps)
/* if we didn't copy map pointers into bpf_prog_info, release
* them now. Otherwise free_used_maps() will release them.
*/
release_maps(env);
if (!env->prog->aux->used_btfs)
release_btfs(env);
/* extension progs temporarily inherit the attach_type of their targets
for verification purposes, so set it back to zero before returning
*/
if (env->prog->type == BPF_PROG_TYPE_EXT)
env->prog->expected_attach_type = 0;
*prog = env->prog;
err_unlock:
if (!is_priv)
mutex_unlock(&bpf_verifier_lock);
vfree(env->insn_aux_data);
err_free_env:
kfree(env);
return ret;
} | 0 |
sqlite | 18f6ff9eb7db02356102283c28053b0a602f55d7 | NOT_APPLICABLE | NOT_APPLICABLE | static int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
Fts3Table *p = (Fts3Table *)pVTab;
int i; /* Iterator variable */
int iCons = -1; /* Index of constraint to use */
int iLangidCons = -1; /* Index of langid=x constraint, if present */
int iDocidGe = -1; /* Index of docid>=x constraint, if present */
int iDocidLe = -1; /* Index of docid<=x constraint, if present */
int iIdx;
/* By default use a full table scan. This is an expensive option,
** so search through the constraints to see if a more efficient
** strategy is possible.
*/
pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
pInfo->estimatedCost = 5000000;
for(i=0; i<pInfo->nConstraint; i++){
int bDocid; /* True if this constraint is on docid */
struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
if( pCons->usable==0 ){
if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH ){
/* There exists an unusable MATCH constraint. This means that if
** the planner does elect to use the results of this call as part
** of the overall query plan the user will see an "unable to use
** function MATCH in the requested context" error. To discourage
** this, return a very high cost here. */
pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
pInfo->estimatedCost = 1e50;
fts3SetEstimatedRows(pInfo, ((sqlite3_int64)1) << 50);
return SQLITE_OK;
}
continue;
}
bDocid = (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1);
/* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */
if( iCons<0 && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ && bDocid ){
pInfo->idxNum = FTS3_DOCID_SEARCH;
pInfo->estimatedCost = 1.0;
iCons = i;
}
/* A MATCH constraint. Use a full-text search.
**
** If there is more than one MATCH constraint available, use the first
** one encountered. If there is both a MATCH constraint and a direct
** rowid/docid lookup, prefer the MATCH strategy. This is done even
** though the rowid/docid lookup is faster than a MATCH query, selecting
** it would lead to an "unable to use function MATCH in the requested
** context" error.
*/
if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH
&& pCons->iColumn>=0 && pCons->iColumn<=p->nColumn
){
pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;
pInfo->estimatedCost = 2.0;
iCons = i;
}
/* Equality constraint on the langid column */
if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ
&& pCons->iColumn==p->nColumn + 2
){
iLangidCons = i;
}
if( bDocid ){
switch( pCons->op ){
case SQLITE_INDEX_CONSTRAINT_GE:
case SQLITE_INDEX_CONSTRAINT_GT:
iDocidGe = i;
break;
case SQLITE_INDEX_CONSTRAINT_LE:
case SQLITE_INDEX_CONSTRAINT_LT:
iDocidLe = i;
break;
}
}
}
iIdx = 1;
if( iCons>=0 ){
pInfo->aConstraintUsage[iCons].argvIndex = iIdx++;
pInfo->aConstraintUsage[iCons].omit = 1;
}
if( iLangidCons>=0 ){
pInfo->idxNum |= FTS3_HAVE_LANGID;
pInfo->aConstraintUsage[iLangidCons].argvIndex = iIdx++;
}
if( iDocidGe>=0 ){
pInfo->idxNum |= FTS3_HAVE_DOCID_GE;
pInfo->aConstraintUsage[iDocidGe].argvIndex = iIdx++;
}
if( iDocidLe>=0 ){
pInfo->idxNum |= FTS3_HAVE_DOCID_LE;
pInfo->aConstraintUsage[iDocidLe].argvIndex = iIdx++;
}
/* Regardless of the strategy selected, FTS can deliver rows in rowid (or
** docid) order. Both ascending and descending are possible.
*/
if( pInfo->nOrderBy==1 ){
struct sqlite3_index_orderby *pOrder = &pInfo->aOrderBy[0];
if( pOrder->iColumn<0 || pOrder->iColumn==p->nColumn+1 ){
if( pOrder->desc ){
pInfo->idxStr = "DESC";
}else{
pInfo->idxStr = "ASC";
}
pInfo->orderByConsumed = 1;
}
}
assert( p->pSegments==0 );
return SQLITE_OK;
} | 0 |
librepo | 7daea2a2429a54dad68b1de9b37a5f65c5cf2600 | NOT_APPLICABLE | NOT_APPLICABLE | lr_yum_use_local(LrHandle *handle, LrResult *result, GError **err)
{
char *baseurl;
LrYumRepo *repo;
LrYumRepoMd *repomd;
assert(!err || *err == NULL);
g_debug("%s: Locating repo..", __func__);
// Shortcuts
repo = result->yum_repo;
repomd = result->yum_repomd;
baseurl = handle->urls[0];
// Skip "file://" prefix if present
if (g_str_has_prefix(baseurl, "file://"))
baseurl += 7;
else if (g_str_has_prefix(baseurl, "file:"))
baseurl += 5;
// Check sanity
if (strstr(baseurl, "://")) {
g_set_error(err, LR_YUM_ERROR, LRE_NOTLOCAL,
"URL: %s doesn't seem to be a local repository",
baseurl);
return FALSE;
}
if (!handle->update) {
// Load repomd.xml and mirrorlist+metalink if locally available
if (!lr_yum_use_local_load_base(handle, result, repo, repomd, baseurl, err))
return FALSE;
}
if(handle->cachedir) {
lr_yum_switch_to_zchunk(handle, repomd);
repo->use_zchunk = TRUE;
} else {
g_debug("%s: Cache directory not set, disabling zchunk", __func__);
repo->use_zchunk = FALSE;
}
// Locate rest of metadata files
for (GSList *elem = repomd->records; elem; elem = g_slist_next(elem)) {
_cleanup_free_ char *path = NULL;
LrYumRepoMdRecord *record = elem->data;
assert(record);
if (!lr_yum_repomd_record_enabled(handle, record->type, repomd->records))
continue; // Caller isn't interested in this record type
if (yum_repo_path(repo, record->type))
continue; // This path already exists in repo
path = lr_pathconcat(baseurl, record->location_href, NULL);
if (access(path, F_OK) == -1) {
// A repo file is missing
if (!handle->ignoremissing) {
g_debug("%s: Incomplete repository - %s is missing",
__func__, path);
g_set_error(err, LR_YUM_ERROR, LRE_INCOMPLETEREPO,
"Incomplete repository - %s is missing",
path);
return FALSE;
}
continue;
}
lr_yum_repo_append(repo, record->type, path);
}
g_debug("%s: Repository was successfully located", __func__);
return TRUE;
} | 0 |
x11vnc | 69eeb9f7baa14ca03b16c9de821f9876def7a36a | NOT_APPLICABLE | NOT_APPLICABLE | static int gap_try(int x, int y, int *run, int *saw, int along_x) {
int n, m, i, xt, yt, ct;
n = x + y * ntiles_x;
if (! tile_has_diff[n]) {
if (*saw) {
(*run)++; /* extend the gap run. */
}
return 0;
}
if (! *saw || *run == 0 || *run > gaps_fill) {
*run = 0; /* unacceptable run. */
*saw = 1;
return 0;
}
for (i=1; i <= *run; i++) { /* iterate thru the run. */
if (along_x) {
xt = x - i;
yt = y;
} else {
xt = x;
yt = y - i;
}
m = xt + yt * ntiles_x;
if (tile_tried[m]) { /* do not repeat tiles */
continue;
}
ct = copy_tiles(xt, yt, 1);
if (ct < 0) return ct; /* fatal */
}
*run = 0;
*saw = 1;
return 1;
} | 0 |
server | 3c209bfc040ddfc41ece8357d772547432353fd2 | NOT_APPLICABLE | NOT_APPLICABLE | void subselect_union_engine::cleanup()
{
DBUG_ENTER("subselect_union_engine::cleanup");
unit->reinit_exec_mechanism();
result->cleanup();
unit->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
sl->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
DBUG_VOID_RETURN;
} | 0 |
server | e1eb39a446c30b8459c39fd7f2ee1c55a36e97d2 | NOT_APPLICABLE | NOT_APPLICABLE | compress_write(ds_file_t *file, const uchar *buf, size_t len)
{
ds_compress_file_t *comp_file;
ds_compress_ctxt_t *comp_ctxt;
comp_thread_ctxt_t *threads;
comp_thread_ctxt_t *thd;
uint nthreads;
uint i;
const char *ptr;
ds_file_t *dest_file;
comp_file = (ds_compress_file_t *) file->ptr;
comp_ctxt = comp_file->comp_ctxt;
dest_file = comp_file->dest_file;
threads = comp_ctxt->threads;
nthreads = comp_ctxt->nthreads;
ptr = (const char *) buf;
while (len > 0) {
uint max_thread;
/* Send data to worker threads for compression */
for (i = 0; i < nthreads; i++) {
size_t chunk_len;
thd = threads + i;
pthread_mutex_lock(&thd->ctrl_mutex);
chunk_len = (len > COMPRESS_CHUNK_SIZE) ?
COMPRESS_CHUNK_SIZE : len;
thd->from = ptr;
thd->from_len = chunk_len;
pthread_mutex_lock(&thd->data_mutex);
thd->data_avail = TRUE;
pthread_cond_signal(&thd->data_cond);
pthread_mutex_unlock(&thd->data_mutex);
len -= chunk_len;
if (len == 0) {
break;
}
ptr += chunk_len;
}
max_thread = (i < nthreads) ? i : nthreads - 1;
/* Reap and stream the compressed data */
for (i = 0; i <= max_thread; i++) {
thd = threads + i;
pthread_mutex_lock(&thd->data_mutex);
while (thd->data_avail == TRUE) {
pthread_cond_wait(&thd->data_cond,
&thd->data_mutex);
}
xb_a(threads[i].to_len > 0);
if (ds_write(dest_file, "NEWBNEWB", 8) ||
write_uint64_le(dest_file,
comp_file->bytes_processed)) {
msg("compress: write to the destination stream "
"failed.");
return 1;
}
comp_file->bytes_processed += threads[i].from_len;
if (write_uint32_le(dest_file, threads[i].adler) ||
ds_write(dest_file, threads[i].to,
threads[i].to_len)) {
msg("compress: write to the destination stream "
"failed.");
return 1;
}
pthread_mutex_unlock(&threads[i].data_mutex);
pthread_mutex_unlock(&threads[i].ctrl_mutex);
}
}
return 0;
} | 0 |
Chrome | eb4d5d9ab41449b79fcf6f84d8983be2b12bd490 | NOT_APPLICABLE | NOT_APPLICABLE | void ContainerNode::removeDetachedChildren()
{
ASSERT(!connectedSubframeCount());
ASSERT(needsAttach());
removeDetachedChildrenInContainer(*this);
}
| 0 |
xserver | 446ff2d3177087b8173fa779fa5b77a2a128988b | NOT_APPLICABLE | NOT_APPLICABLE | _XkbFindNamedIndicatorMap(XkbSrvLedInfoPtr sli, Atom indicator, int *led_return)
{
XkbIndicatorMapPtr map;
/* search for the right indicator */
map = NULL;
if (sli->names && sli->maps) {
int led;
for (led = 0; (led < XkbNumIndicators) && (map == NULL); led++) {
if (sli->names[led] == indicator) {
map = &sli->maps[led];
*led_return = led;
break;
}
}
}
return map;
} | 0 |
rufus | c3c39f7f8a11f612c4ebf7affce25ec6928eb1cb | NOT_APPLICABLE | NOT_APPLICABLE | void BrowseForFolder(void) {
BROWSEINFOW bi;
LPITEMIDLIST pidl;
WCHAR *wpath;
size_t i;
HRESULT hr;
IShellItem *psi = NULL;
IShellItem *si_path = NULL; // Automatically freed
IFileOpenDialog *pfod = NULL;
WCHAR *fname;
char* tmp_path = NULL;
dialog_showing++;
if (nWindowsVersion >= WINDOWS_VISTA) {
INIT_VISTA_SHELL32;
if (IS_VISTA_SHELL32_AVAILABLE) {
hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
&IID_IFileOpenDialog, (LPVOID)&pfod);
if (FAILED(hr)) {
uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr);
pfod = NULL; // Just in case
goto fallback;
}
hr = pfod->lpVtbl->SetOptions(pfod, FOS_PICKFOLDERS);
if (FAILED(hr)) {
uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr);
goto fallback;
}
wpath = utf8_to_wchar(szFolderPath);
fname = NULL;
if ((wpath != NULL) && (wcslen(wpath) >= 1)) {
for (i = wcslen(wpath) - 1; i != 0; i--) {
if (wpath[i] == L'\\') {
wpath[i] = 0;
fname = &wpath[i + 1];
break;
}
}
}
hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path);
if (SUCCEEDED(hr)) {
if (wpath != NULL) {
pfod->lpVtbl->SetFolder(pfod, si_path);
}
if (fname != NULL) {
pfod->lpVtbl->SetFileName(pfod, fname);
}
}
safe_free(wpath);
hr = pfod->lpVtbl->Show(pfod, hMainDialog);
if (SUCCEEDED(hr)) {
hr = pfod->lpVtbl->GetResult(pfod, &psi);
if (SUCCEEDED(hr)) {
psi->lpVtbl->GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath);
tmp_path = wchar_to_utf8(wpath);
CoTaskMemFree(wpath);
if (tmp_path == NULL) {
uprintf("Could not convert path\n");
} else {
static_strcpy(szFolderPath, tmp_path);
safe_free(tmp_path);
}
} else {
uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr);
}
} else if ((hr & 0xFFFF) != ERROR_CANCELLED) {
uprintf("Could not show FileOpenDialog: error %X\n", hr);
goto fallback;
}
pfod->lpVtbl->Release(pfod);
dialog_showing--;
return;
}
fallback:
if (pfod != NULL) {
pfod->lpVtbl->Release(pfod);
}
}
INIT_XP_SHELL32;
memset(&bi, 0, sizeof(BROWSEINFOW));
bi.hwndOwner = hMainDialog;
bi.lpszTitle = utf8_to_wchar(lmprintf(MSG_106));
bi.lpfn = BrowseInfoCallback;
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS |
BIF_DONTGOBELOWDOMAIN | BIF_EDITBOX | 0x00000200;
pidl = SHBrowseForFolderW(&bi);
if (pidl != NULL) {
CoTaskMemFree(pidl);
}
safe_free(bi.lpszTitle);
dialog_showing--;
}
| 0 |
evolution-data-server | 6672b8236139bd6ef41ecb915f4c72e2a052dba5 | NOT_APPLICABLE | NOT_APPLICABLE | e_named_parameters_clear (ENamedParameters *parameters)
{
GPtrArray *array;
g_return_if_fail (parameters != NULL);
array = (GPtrArray *) parameters;
if (array->len)
g_ptr_array_remove_range (array, 0, array->len);
} | 0 |
Chrome | 5d78b84d39bd34bc9fce9d01c0dcd5a22a330d34 | NOT_APPLICABLE | NOT_APPLICABLE | LayerTreeHost::~LayerTreeHost() {
CHECK(!inside_main_frame_);
TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess");
mutator_host_->SetMutatorHostClient(nullptr);
RegisterViewportLayers(nullptr, nullptr, nullptr, nullptr);
if (root_layer_) {
root_layer_->SetLayerTreeHost(nullptr);
root_layer_ = nullptr;
}
if (proxy_) {
DCHECK(task_runner_provider_->IsMainThread());
proxy_->Stop();
proxy_ = nullptr;
}
}
| 0 |
mongoose | c65c8fdaaa257e0487ab0aaae9e8f6b439335945 | NOT_APPLICABLE | NOT_APPLICABLE | static void write_conn(struct mg_connection *c) {
char *buf = (char *) c->send.buf;
size_t len = c->send.len;
long n = c->is_tls ? mg_tls_send(c, buf, len) : mg_sock_send(c, buf, len);
iolog(c, buf, n, false);
} | 0 |
linux | 550fd08c2cebad61c548def135f67aba284c6162 | NOT_APPLICABLE | NOT_APPLICABLE | static int airo_get_wap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *awrq,
char *extra)
{
struct airo_info *local = dev->ml_priv;
StatusRid status_rid; /* Card status info */
readStatusRid(local, &status_rid, 1);
/* Tentative. This seems to work, wow, I'm lucky !!! */
memcpy(awrq->sa_data, status_rid.bssid[0], ETH_ALEN);
awrq->sa_family = ARPHRD_ETHER;
return 0;
}
| 0 |
linux | 4a1d704194a441bf83c636004a479e01360ec850 | NOT_APPLICABLE | NOT_APPLICABLE | static int insert_page(struct vm_area_struct *vma, unsigned long addr,
struct page *page, pgprot_t prot)
{
struct mm_struct *mm = vma->vm_mm;
int retval;
pte_t *pte;
spinlock_t *ptl;
retval = -EINVAL;
if (PageAnon(page))
goto out;
retval = -ENOMEM;
flush_dcache_page(page);
pte = get_locked_pte(mm, addr, &ptl);
if (!pte)
goto out;
retval = -EBUSY;
if (!pte_none(*pte))
goto out_unlock;
/* Ok, finally just insert the thing.. */
get_page(page);
inc_mm_counter_fast(mm, MM_FILEPAGES);
page_add_file_rmap(page);
set_pte_at(mm, addr, pte, mk_pte(page, prot));
retval = 0;
pte_unmap_unlock(pte, ptl);
return retval;
out_unlock:
pte_unmap_unlock(pte, ptl);
out:
return retval;
}
| 0 |
linux | 32452a3eb8b64e01e2be717f518c0be046975b9d | NOT_APPLICABLE | NOT_APPLICABLE |
static void io_eventfd_put(struct rcu_head *rcu)
{
struct io_ev_fd *ev_fd = container_of(rcu, struct io_ev_fd, rcu);
eventfd_ctx_put(ev_fd->cq_ev_fd);
kfree(ev_fd); | 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | static bool is_inf(const cimg_int64) { return false; } | 0 |
FreeRDP | 3627aaf7d289315b614a584afb388f04abfb5bbf | NOT_APPLICABLE | NOT_APPLICABLE | static void rdp_read_capability_set_header(wStream* s, UINT16* length, UINT16* type)
{
Stream_Read_UINT16(s, *type); /* capabilitySetType */
Stream_Read_UINT16(s, *length); /* lengthCapability */
} | 0 |
Chrome | dc5edc9c05901feeac616c075d0337e634f3a02a | NOT_APPLICABLE | NOT_APPLICABLE | struct tm* localtime64_r_override(const time_t* timep, struct tm* result) {
if (g_am_zygote_or_renderer) {
ProxyLocaltimeCallToBrowser(*timep, result, NULL, 0);
return result;
}
CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard,
InitLibcLocaltimeFunctions));
struct tm* res = g_libc_localtime64_r(timep, result);
#if defined(MEMORY_SANITIZER)
if (res) __msan_unpoison(res, sizeof(*res));
if (res->tm_zone) __msan_unpoison_string(res->tm_zone);
#endif
return res;
}
| 0 |
openssl | 3c66a669dfc7b3792f7af0758ea26fe8502ce70c | NOT_APPLICABLE | NOT_APPLICABLE | int ssl3_get_certificate_request(SSL *s)
{
int ok, ret = 0;
unsigned long n, nc, l;
unsigned int llen, ctype_num, i;
X509_NAME *xn = NULL;
const unsigned char *p, *q;
unsigned char *d;
STACK_OF(X509_NAME) *ca_sk = NULL;
n = s->method->ssl_get_message(s,
SSL3_ST_CR_CERT_REQ_A,
SSL3_ST_CR_CERT_REQ_B,
-1, s->max_cert_list, &ok);
if (!ok)
return ((int)n);
s->s3->tmp.cert_req = 0;
if (s->s3->tmp.message_type == SSL3_MT_SERVER_DONE) {
s->s3->tmp.reuse_message = 1;
/*
* If we get here we don't need any cached handshake records as we
* wont be doing client auth.
*/
if (s->s3->handshake_buffer) {
if (!ssl3_digest_cached_records(s))
goto err;
}
return (1);
}
if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_REQUEST) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_WRONG_MESSAGE_TYPE);
goto err;
}
/* TLS does not like anon-DH with client cert */
if (s->version > SSL3_VERSION) {
if (s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,
SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER);
goto err;
}
}
p = d = (unsigned char *)s->init_msg;
if ((ca_sk = sk_X509_NAME_new(ca_dn_cmp)) == NULL) {
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);
goto err;
}
/* get the certificate types */
ctype_num = *(p++);
if (s->cert->ctypes) {
OPENSSL_free(s->cert->ctypes);
s->cert->ctypes = NULL;
}
if (ctype_num > SSL3_CT_NUMBER) {
/* If we exceed static buffer copy all to cert structure */
s->cert->ctypes = OPENSSL_malloc(ctype_num);
memcpy(s->cert->ctypes, p, ctype_num);
s->cert->ctype_num = (size_t)ctype_num;
ctype_num = SSL3_CT_NUMBER;
}
for (i = 0; i < ctype_num; i++)
s->s3->tmp.ctype[i] = p[i];
p += p[-1];
if (SSL_USE_SIGALGS(s)) {
n2s(p, llen);
/*
* Check we have enough room for signature algorithms and following
* length value.
*/
if ((unsigned long)(p - d + llen + 2) > n) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,
SSL_R_DATA_LENGTH_TOO_LONG);
goto err;
}
/* Clear certificate digests and validity flags */
for (i = 0; i < SSL_PKEY_NUM; i++) {
s->cert->pkeys[i].digest = NULL;
s->cert->pkeys[i].valid_flags = 0;
}
if ((llen & 1) || !tls1_save_sigalgs(s, p, llen)) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,
SSL_R_SIGNATURE_ALGORITHMS_ERROR);
goto err;
}
if (!tls1_process_sigalgs(s)) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);
goto err;
}
p += llen;
}
/* get the CA RDNs */
n2s(p, llen);
#if 0
{
FILE *out;
out = fopen("/tmp/vsign.der", "w");
fwrite(p, 1, llen, out);
fclose(out);
}
#endif
if ((unsigned long)(p - d + llen) != n) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH);
goto err;
}
for (nc = 0; nc < llen;) {
n2s(p, l);
if ((l + nc + 2) > llen) {
if ((s->options & SSL_OP_NETSCAPE_CA_DN_BUG))
goto cont; /* netscape bugs */
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_CA_DN_TOO_LONG);
goto err;
}
q = p;
if ((xn = d2i_X509_NAME(NULL, &q, l)) == NULL) {
/* If netscape tolerance is on, ignore errors */
if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG)
goto cont;
else {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_ASN1_LIB);
goto err;
}
}
if (q != (p + l)) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,
SSL_R_CA_DN_LENGTH_MISMATCH);
goto err;
}
if (!sk_X509_NAME_push(ca_sk, xn)) {
SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);
goto err;
}
p += l;
nc += l + 2;
}
if (0) {
cont:
ERR_clear_error();
}
/* we should setup a certificate to return.... */
s->s3->tmp.cert_req = 1;
s->s3->tmp.ctype_num = ctype_num;
if (s->s3->tmp.ca_names != NULL)
sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
s->s3->tmp.ca_names = ca_sk;
ca_sk = NULL;
ret = 1;
goto done;
err:
s->state = SSL_ST_ERR;
done:
if (ca_sk != NULL)
sk_X509_NAME_pop_free(ca_sk, X509_NAME_free);
return (ret);
}
| 0 |
libarchive | d0331e8e5b05b475f20b1f3101fe1ad772d7e7e7 | NOT_APPLICABLE | NOT_APPLICABLE | archive_read_format_zip_has_encrypted_entries(struct archive_read *_a)
{
if (_a && _a->format) {
struct zip * zip = (struct zip *)_a->format->data;
if (zip) {
return zip->has_encrypted_entries;
}
}
return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
}
| 0 |
linux | bb1fceca22492109be12640d49f5ea5a544c6bb4 | NOT_APPLICABLE | NOT_APPLICABLE | static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
{
return tp->packets_out - tcp_left_out(tp) + tp->retrans_out;
} | 0 |
FFmpeg | 611b35627488a8d0763e75c25ee0875c5b7987dd | NOT_APPLICABLE | NOT_APPLICABLE | static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
const uint8_t *buf, int buf_size)
{
ParseContext *pc = &dctx->pc;
uint64_t state = pc->state64;
int pic_found = pc->frame_start_found;
int i = 0;
if (!pic_found) {
for (i = 0; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (ff_dnxhd_check_header_prefix(state & 0xffffffffff00LL) != 0) {
i++;
pic_found = 1;
dctx->cur_byte = 0;
dctx->remaining = 0;
break;
}
}
}
if (pic_found && !dctx->remaining) {
if (!buf_size) /* EOF considered as end of frame */
return 0;
for (; i < buf_size; i++) {
dctx->cur_byte++;
state = (state << 8) | buf[i];
if (dctx->cur_byte == 24) {
dctx->h = (state >> 32) & 0xFFFF;
} else if (dctx->cur_byte == 26) {
dctx->w = (state >> 32) & 0xFFFF;
} else if (dctx->cur_byte == 42) {
int cid = (state >> 32) & 0xFFFFFFFF;
int remaining;
if (cid <= 0)
continue;
remaining = avpriv_dnxhd_get_frame_size(cid);
if (remaining <= 0) {
remaining = ff_dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h);
if (remaining <= 0)
continue;
}
dctx->remaining = remaining;
if (buf_size - i + 47 >= dctx->remaining) {
int remaining = dctx->remaining;
pc->frame_start_found = 0;
pc->state64 = -1;
dctx->cur_byte = 0;
dctx->remaining = 0;
return remaining;
} else {
dctx->remaining -= buf_size;
}
}
}
} else if (pic_found) {
if (dctx->remaining > buf_size) {
dctx->remaining -= buf_size;
} else {
int remaining = dctx->remaining;
pc->frame_start_found = 0;
pc->state64 = -1;
dctx->cur_byte = 0;
dctx->remaining = 0;
return remaining;
}
}
pc->frame_start_found = pic_found;
pc->state64 = state;
return END_NOT_FOUND;
}
| 0 |
php-src | 760ff841a14160f25348f7969985cb8a2c4da3cc | NOT_APPLICABLE | NOT_APPLICABLE | ZEND_API int ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ */
{
try_again:
switch (Z_TYPE_P(op1)) {
case IS_LONG:
ZVAL_LONG(result, ~Z_LVAL_P(op1));
return SUCCESS;
case IS_DOUBLE:
ZVAL_LONG(result, ~zend_dval_to_lval(Z_DVAL_P(op1)));
return SUCCESS;
case IS_STRING: {
size_t i;
if (Z_STRLEN_P(op1) == 1) {
zend_uchar not = (zend_uchar) ~*Z_STRVAL_P(op1);
ZVAL_INTERNED_STR(result, ZSTR_CHAR(not));
} else {
ZVAL_NEW_STR(result, zend_string_alloc(Z_STRLEN_P(op1), 0));
for (i = 0; i < Z_STRLEN_P(op1); i++) {
Z_STRVAL_P(result)[i] = ~Z_STRVAL_P(op1)[i];
}
Z_STRVAL_P(result)[i] = 0;
}
return SUCCESS;
}
case IS_REFERENCE:
op1 = Z_REFVAL_P(op1);
goto try_again;
default:
ZEND_TRY_UNARY_OBJECT_OPERATION(ZEND_BW_NOT);
if (result != op1) {
ZVAL_UNDEF(result);
}
zend_throw_error(NULL, "Unsupported operand types");
return FAILURE;
}
} | 0 |
linux | 12f09ccb4612734a53e47ed5302e0479c10a50f8 | NOT_APPLICABLE | NOT_APPLICABLE | static int tcm_loop_check_demo_mode_write_protect(struct se_portal_group *se_tpg)
{
return 0;
}
| 0 |
httpd | 29c63b786ae028d82405421585e91283c8fa0da3 | NOT_APPLICABLE | NOT_APPLICABLE | static int on_send_data_cb(nghttp2_session *ngh2,
nghttp2_frame *frame,
const uint8_t *framehd,
size_t length,
nghttp2_data_source *source,
void *userp)
{
apr_status_t status = APR_SUCCESS;
h2_session *session = (h2_session *)userp;
int stream_id = (int)frame->hd.stream_id;
unsigned char padlen;
int eos;
h2_stream *stream;
apr_bucket *b;
apr_off_t len = length;
(void)ngh2;
(void)source;
if (frame->data.padlen > H2_MAX_PADLEN) {
return NGHTTP2_ERR_PROTO;
}
padlen = (unsigned char)frame->data.padlen;
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
"h2_stream(%ld-%d): send_data_cb for %ld bytes",
session->id, (int)stream_id, (long)length);
stream = get_stream(session, stream_id);
if (!stream) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_NOTFOUND, session->c,
APLOGNO(02924)
"h2_stream(%ld-%d): send_data, lookup stream",
session->id, (int)stream_id);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
status = h2_conn_io_write(&session->io, (const char *)framehd, 9);
if (padlen && status == APR_SUCCESS) {
status = h2_conn_io_write(&session->io, (const char *)&padlen, 1);
}
if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c,
"h2_stream(%ld-%d): writing frame header",
session->id, (int)stream_id);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
status = h2_stream_read_to(stream, session->bbtmp, &len, &eos);
if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c,
"h2_stream(%ld-%d): send_data_cb, reading stream",
session->id, (int)stream_id);
apr_brigade_cleanup(session->bbtmp);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
else if (len != length) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c,
"h2_stream(%ld-%d): send_data_cb, wanted %ld bytes, "
"got %ld from stream",
session->id, (int)stream_id, (long)length, (long)len);
apr_brigade_cleanup(session->bbtmp);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
if (padlen) {
b = apr_bucket_immortal_create(immortal_zeros, padlen,
session->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(session->bbtmp, b);
}
status = h2_conn_io_pass(&session->io, session->bbtmp);
apr_brigade_cleanup(session->bbtmp);
if (status == APR_SUCCESS) {
stream->out_data_frames++;
stream->out_data_octets += length;
return 0;
}
else {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c,
APLOGNO(02925)
"h2_stream(%ld-%d): failed send_data_cb",
session->id, (int)stream_id);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
| 0 |
gpac | f19668964bf422cf5a63e4dbe1d3c6c75edadcbb | NOT_APPLICABLE | NOT_APPLICABLE | GF_Err sinf_box_read(GF_Box *s, GF_BitStream *bs)
{
return gf_isom_box_array_read(s, bs);
} | 0 |
Chrome | c13e1da62b5f5f0e6fe8c1f769a5a28415415244 | NOT_APPLICABLE | NOT_APPLICABLE | error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
uint32 immediate_data_size, const gles2::VertexAttribPointer& c) {
if (!bound_array_buffer_ || bound_array_buffer_->IsDeleted()) {
SetGLError(GL_INVALID_VALUE,
"glVertexAttribPointer: no array buffer bound");
return error::kNoError;
}
GLuint indx = c.indx;
GLint size = c.size;
GLenum type = c.type;
GLboolean normalized = c.normalized;
GLsizei stride = c.stride;
GLsizei offset = c.offset;
const void* ptr = reinterpret_cast<const void*>(offset);
if (!validators_->vertex_attrib_type.IsValid(type)) {
SetGLError(GL_INVALID_ENUM,
"glVertexAttribPointer: type GL_INVALID_ENUM");
return error::kNoError;
}
if (!validators_->vertex_attrib_size.IsValid(size)) {
SetGLError(GL_INVALID_VALUE,
"glVertexAttribPointer: size GL_INVALID_VALUE");
return error::kNoError;
}
if (indx >= group_->max_vertex_attribs()) {
SetGLError(GL_INVALID_VALUE, "glVertexAttribPointer: index out of range");
return error::kNoError;
}
if (stride < 0) {
SetGLError(GL_INVALID_VALUE,
"glVertexAttribPointer: stride < 0");
return error::kNoError;
}
if (stride > 255) {
SetGLError(GL_INVALID_VALUE,
"glVertexAttribPointer: stride > 255");
return error::kNoError;
}
if (offset < 0) {
SetGLError(GL_INVALID_VALUE,
"glVertexAttribPointer: offset < 0");
return error::kNoError;
}
GLsizei component_size =
GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type);
if (offset % component_size > 0) {
SetGLError(GL_INVALID_OPERATION,
"glVertexAttribPointer: offset not valid for type");
return error::kNoError;
}
if (stride % component_size > 0) {
SetGLError(GL_INVALID_OPERATION,
"glVertexAttribPointer: stride not valid for type");
return error::kNoError;
}
vertex_attrib_manager_.SetAttribInfo(
indx,
bound_array_buffer_,
size,
type,
normalized,
stride,
stride != 0 ? stride : component_size * size,
offset);
if (type != GL_FIXED) {
glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
return error::kNoError;
}
| 0 |
Chrome | a9cbaa7a40e2b2723cfc2f266c42f4980038a949 | NOT_APPLICABLE | NOT_APPLICABLE | bool IsPlayableTrack(const blink::WebMediaStreamTrack& track) {
return !track.IsNull() && !track.Source().IsNull() &&
track.Source().GetReadyState() !=
blink::WebMediaStreamSource::kReadyStateEnded;
}
| 0 |
htcondor | 5e5571d1a431eb3c61977b6dd6ec90186ef79867 | NOT_APPLICABLE | NOT_APPLICABLE | CStarter::RemoteHold( int )
{
if( jic ) {
jic->gotHold();
}
if ( this->Hold( ) ) {
dprintf( D_FULLDEBUG, "Got Hold when no jobs running\n" );
this->allJobsDone();
return ( true );
}
return ( false );
}
| 0 |
Chrome | 8f3a9a68b2dcdd2c54cf49a41ad34729ab576702 | NOT_APPLICABLE | NOT_APPLICABLE | Browser::CreateParams::CreateParams(Type type, Profile* profile)
: type(type),
profile(profile),
trusted_source(false),
initial_show_state(ui::SHOW_STATE_DEFAULT),
is_session_restore(false),
window(NULL) {}
| 0 |
net | b922f622592af76b57cbc566eaeccda0b31a3496 | NOT_APPLICABLE | NOT_APPLICABLE | static int hw_atl_fw1x_deinit(struct aq_hw_s *self)
{
hw_atl_utils_mpi_set_speed(self, 0);
hw_atl_utils_mpi_set_state(self, MPI_DEINIT);
return 0;
} | 0 |
qemu | 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3 | NOT_APPLICABLE | NOT_APPLICABLE | void vnc_display_init(const char *id)
{
VncDisplay *vs;
if (vnc_display_find(id) != NULL) {
return;
}
vs = g_malloc0(sizeof(*vs));
vs->id = strdup(id);
QTAILQ_INSERT_TAIL(&vnc_displays, vs, next);
vs->lsock = -1;
vs->lwebsock = -1;
QTAILQ_INIT(&vs->clients);
vs->expires = TIME_MAX;
if (keyboard_layout) {
trace_vnc_key_map_init(keyboard_layout);
vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
} else {
vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
}
if (!vs->kbd_layout)
exit(1);
qemu_mutex_init(&vs->mutex);
vnc_start_worker_thread();
vs->dcl.ops = &dcl_ops;
register_displaychangelistener(&vs->dcl);
} | 0 |
qBittorrent | f5ad04766f4abaa78374ff03704316f8ce04627d | NOT_APPLICABLE | NOT_APPLICABLE | void AbstractWebApplication::UnbanTimerEvent()
{
UnbanTimer* ubantimer = static_cast<UnbanTimer*>(sender());
qDebug("Ban period has expired for %s", qPrintable(ubantimer->peerIp().toString()));
clientFailedAttempts_.remove(ubantimer->peerIp());
ubantimer->deleteLater();
} | 0 |
libyang | 298b30ea4ebee137226acf9bb38678bd82704582 | NOT_APPLICABLE | NOT_APPLICABLE | lyxml_print_fd(int fd, const struct lyxml_elem *elem, int options)
{
FUN_IN;
struct lyout out;
if (fd < 0 || !elem) {
return 0;
}
memset(&out, 0, sizeof out);
out.type = LYOUT_FD;
out.method.fd = fd;
if (options & LYXML_PRINT_SIBLINGS) {
return dump_siblings(&out, elem, options);
} else {
return dump_elem(&out, elem, 0, options, 1);
}
} | 0 |
OpenSC | 360e95d45ac4123255a4c796db96337f332160ad | NOT_APPLICABLE | NOT_APPLICABLE | static int muscle_card_generate_key(sc_card_t *card, sc_cardctl_muscle_gen_key_info_t *info)
{
return msc_generate_keypair(card,
info->privateKeyLocation,
info->publicKeyLocation,
info->keyType,
info->keySize,
0);
} | 0 |
unicorn | c733bbada356b0373fa8aa72c044574bb855fd24 | NOT_APPLICABLE | NOT_APPLICABLE | static bool tb_exec_is_locked(TCGContext *tcg_ctx)
{
return false;
} | 0 |
libvirt | 524de6cc35d3b222f0e940bb0fd027f5482572c5 | CVE-2020-14301 | CWE-212 | testBackingParse(const void *args)
{
const struct testBackingParseData *data = args;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *xml = NULL;
g_autoptr(virStorageSource) src = NULL;
int rc;
int erc = data->rv;
/* expect failure return code with NULL expected data */
if (!data->expect)
erc = -1;
if ((rc = virStorageSourceNewFromBackingAbsolute(data->backing, &src)) != erc) {
fprintf(stderr, "expected return value '%d' actual '%d'\n", erc, rc);
return -1;
}
if (!src)
return 0;
if (src && !data->expect) {
fprintf(stderr, "parsing of backing store string '%s' should "
"have failed\n", data->backing);
return -1;
}
if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, 0, true, NULL) < 0 ||
!(xml = virBufferContentAndReset(&buf))) {
fprintf(stderr, "failed to format disk source xml\n");
return -1;
}
if (STRNEQ(xml, data->expect)) {
fprintf(stderr, "\n backing store string '%s'\n"
"expected storage source xml:\n%s\n"
"actual storage source xml:\n%s\n",
data->backing, data->expect, xml);
return -1;
}
return 0;
} | 1 |
gpac | bceb03fd2be95097a7b409ea59914f332fb6bc86 | NOT_APPLICABLE | NOT_APPLICABLE | GF_Err stsh_Read(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
u32 count, i;
GF_StshEntry *ent;
GF_ShadowSyncBox *ptr = (GF_ShadowSyncBox *)s;
count = gf_bs_read_u32(bs);
for (i = 0; i < count; i++) {
ent = (GF_StshEntry *) gf_malloc(sizeof(GF_StshEntry));
if (!ent) return GF_OUT_OF_MEM;
ent->shadowedSampleNumber = gf_bs_read_u32(bs);
ent->syncSampleNumber = gf_bs_read_u32(bs);
e = gf_list_add(ptr->entries, ent);
if (e) return e;
}
return GF_OK;
}
| 0 |
linux | d80b64ff297e40c2b6f7d7abc1b3eba70d22a068 | NOT_APPLICABLE | NOT_APPLICABLE | static inline void disable_gif(struct vcpu_svm *svm)
{
if (vgif_enabled(svm))
svm->vmcb->control.int_ctl &= ~V_GIF_MASK;
else
svm->vcpu.arch.hflags &= ~HF_GIF_MASK;
} | 0 |
git | 7c3745fc6185495d5765628b4dfe1bd2c25a2981 | NOT_APPLICABLE | NOT_APPLICABLE | static void strbuf_worktree_gitdir(struct strbuf *buf,
const struct repository *repo,
const struct worktree *wt)
{
if (!wt)
strbuf_addstr(buf, repo->gitdir);
else if (!wt->id)
strbuf_addstr(buf, repo->commondir);
else
strbuf_git_common_path(buf, repo, "worktrees/%s", wt->id);
} | 0 |
linux | 9f645bcc566a1e9f921bdae7528a01ced5bc3713 | NOT_APPLICABLE | NOT_APPLICABLE | static void uvesafb_vbe_state_restore(struct uvesafb_par *par, u8 *state_buf)
{
struct uvesafb_ktask *task;
int err;
if (!state_buf)
return;
task = uvesafb_prep();
if (!task)
return;
task->t.regs.eax = 0x4f04;
task->t.regs.ecx = 0x000f;
task->t.regs.edx = 0x0002;
task->t.buf_len = par->vbe_state_size;
task->t.flags = TF_BUF_ESBX;
task->buf = state_buf;
err = uvesafb_exec(task);
if (err || (task->t.regs.eax & 0xffff) != 0x004f)
pr_warn("VBE state restore call failed (eax=0x%x, err=%d)\n",
task->t.regs.eax, err);
uvesafb_free(task);
}
| 0 |
linux | 81b1d548d00bcd028303c4f3150fa753b9b8aa71 | NOT_APPLICABLE | NOT_APPLICABLE | static int sp_open_dev(struct net_device *dev)
{
struct sixpack *sp = netdev_priv(dev);
if (sp->tty == NULL)
return -ENODEV;
return 0;
} | 0 |
Chrome | a8d6ae61d266d8bc44c3dd2d08bda32db701e359 | NOT_APPLICABLE | NOT_APPLICABLE | bool ChromeDownloadManagerDelegate::ShouldOpenDownload(
DownloadItem* item, const content::DownloadOpenDelayedCallback& callback) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (download_crx_util::IsExtensionDownload(*item) &&
!extensions::WebstoreInstaller::GetAssociatedApproval(*item)) {
scoped_refptr<extensions::CrxInstaller> crx_installer =
download_crx_util::OpenChromeExtension(profile_, *item);
registrar_.Add(
this,
extensions::NOTIFICATION_CRX_INSTALLER_DONE,
content::Source<extensions::CrxInstaller>(crx_installer.get()));
crx_installers_[crx_installer.get()] = callback;
item->UpdateObservers();
return false;
}
#endif
return true;
}
| 0 |
Chrome | b2dfe7c175fb21263f06eb586f1ed235482a3281 | NOT_APPLICABLE | NOT_APPLICABLE | Eina_Bool ewk_frame_feed_mouse_down(Evas_Object* ewkFrame, const Evas_Event_Mouse_Down* downEvent)
{
EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(downEvent, false);
WebCore::FrameView* view = smartData->frame->view();
DBG("ewkFrame=%p, view=%p, button=%d, pos=%d,%d",
ewkFrame, view, downEvent->button, downEvent->canvas.x, downEvent->canvas.y);
EINA_SAFETY_ON_NULL_RETURN_VAL(view, false);
Evas_Coord x, y;
evas_object_geometry_get(smartData->view, &x, &y, 0, 0);
WebCore::PlatformMouseEvent event(downEvent, WebCore::IntPoint(x, y));
return smartData->frame->eventHandler()->handleMousePressEvent(event);
}
| 0 |
core | 266e54b7b8c34c9a58dd60a2e53c5ca7d1deae19 | NOT_APPLICABLE | NOT_APPLICABLE | imap_bodystructure_params_parse(const struct imap_arg *arg,
pool_t pool, const struct message_part_param **params_r,
unsigned int *count_r)
{
struct message_part_param *params;
const struct imap_arg *list_args;
unsigned int list_count, params_count, i;
if (arg->type == IMAP_ARG_NIL) {
*params_r = NULL;
return 0;
}
if (!imap_arg_get_list_full(arg, &list_args, &list_count))
return -1;
if ((list_count % 2) != 0)
return -1;
params_count = list_count/2;
params = p_new(pool, struct message_part_param, params_count+1);
for (i = 0; i < params_count; i++) {
const char *name, *value;
if (!imap_arg_get_nstring(&list_args[i*2+0], &name))
return -1;
if (!imap_arg_get_nstring(&list_args[i*2+1], &value))
return -1;
params[i].name = p_strdup(pool, name);
params[i].value = p_strdup(pool, value);
}
*params_r = params;
*count_r = params_count;
return 0;
} | 0 |
OpenJK | f61fe5f6a0419ef4a88d46a128052f2e8352e85d | NOT_APPLICABLE | NOT_APPLICABLE | static void S_AL_AllocateStreamChannel(int stream, int entityNum)
{
srcHandle_t cursrc;
ALuint alsrc;
if ((stream < 0) || (stream >= MAX_RAW_STREAMS))
return;
if(entityNum >= 0)
{
cursrc = S_AL_SrcAlloc(SRCPRI_ENTITY, entityNum, 0);
if(cursrc < 0)
return;
S_AL_SrcSetup(cursrc, -1, SRCPRI_ENTITY, entityNum, 0, qfalse);
alsrc = S_AL_SrcGet(cursrc);
srcList[cursrc].isTracking = qtrue;
srcList[cursrc].isStream = qtrue;
}
else
{
cursrc = S_AL_SrcAlloc(SRCPRI_STREAM, -2, 0);
if(cursrc < 0)
return;
alsrc = S_AL_SrcGet(cursrc);
S_AL_SrcLock(cursrc);
srcList[cursrc].scaleGain = 0.0f;
qalSourcei (alsrc, AL_BUFFER, 0 );
qalSourcei (alsrc, AL_LOOPING, AL_FALSE );
qalSource3f(alsrc, AL_POSITION, 0.0, 0.0, 0.0);
qalSource3f(alsrc, AL_VELOCITY, 0.0, 0.0, 0.0);
qalSource3f(alsrc, AL_DIRECTION, 0.0, 0.0, 0.0);
qalSourcef (alsrc, AL_ROLLOFF_FACTOR, 0.0 );
qalSourcei (alsrc, AL_SOURCE_RELATIVE, AL_TRUE );
}
streamSourceHandles[stream] = cursrc;
streamSources[stream] = alsrc;
streamNumBuffers[stream] = 0;
streamBufIndex[stream] = 0;
}
| 0 |
libexpat | c20b758c332d9a13afbbb276d30db1d183a85d43 | NOT_APPLICABLE | NOT_APPLICABLE | writeRandomBytes_getrandom_nonblock(void *target, size_t count) {
int success = 0; /* full count bytes written? */
size_t bytesWrittenTotal = 0;
const unsigned int getrandomFlags = GRND_NONBLOCK;
do {
void *const currentTarget = (void *)((char *)target + bytesWrittenTotal);
const size_t bytesToWrite = count - bytesWrittenTotal;
const int bytesWrittenMore =
# if defined(HAVE_GETRANDOM)
getrandom(currentTarget, bytesToWrite, getrandomFlags);
# else
syscall(SYS_getrandom, currentTarget, bytesToWrite, getrandomFlags);
# endif
if (bytesWrittenMore > 0) {
bytesWrittenTotal += bytesWrittenMore;
if (bytesWrittenTotal >= count)
success = 1;
}
} while (! success && (errno == EINTR));
return success;
}
| 0 |
rsyslog | 8083bd1433449fd2b1b79bf759f782e0f64c0cd2 | NOT_APPLICABLE | NOT_APPLICABLE | static inline void prepareProgramName(msg_t *pM, sbool bLockMutex)
{
if(pM->pCSProgName == NULL) {
if(bLockMutex == LOCK_MUTEX)
MsgLock(pM);
/* re-query as things might have changed during locking */
if(pM->pCSProgName == NULL)
aquireProgramName(pM);
if(bLockMutex == LOCK_MUTEX)
MsgUnlock(pM);
}
} | 0 |
Chrome | faaa2fd0a05f1622d9a8806da118d4f3b602e707 | NOT_APPLICABLE | NOT_APPLICABLE | bool HTMLMediaElement::supportsSave() const {
return webMediaPlayer() && webMediaPlayer()->supportsSave();
}
| 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | template<typename t>
CImg<T>& operator<<=(const CImg<t>& img) {
const ulongT siz = size(), isiz = img.size();
if (siz && isiz) {
if (is_overlapped(img)) return *this^=+img;
T *ptrd = _data, *const ptre = _data + siz;
if (siz>isiz) for (ulongT n = siz/isiz; n; --n)
for (const t *ptrs = img._data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd)
*ptrd = (T)((longT)*ptrd << (int)*(ptrs++));
for (const t *ptrs = img._data; ptrd<ptre; ++ptrd) *ptrd = (T)((longT)*ptrd << (int)*(ptrs++));
}
return *this; | 0 |
Chrome | 1924f747637265f563892b8f56a64391f6208194 | NOT_APPLICABLE | NOT_APPLICABLE | void TrayCast::UpdatePrimaryView() {
if (HasCastExtension() == false) {
if (default_)
default_->SetVisible(false);
if (tray_) {
base::MessageLoopForUI::current()->PostTask(
FROM_HERE, base::Bind(&tray::CastTrayView::SetVisible,
tray_->AsWeakPtr(), false));
}
} else {
if (default_) {
if (is_casting_)
default_->ActivateCastView();
else
default_->ActivateSelectView();
}
if (tray_)
tray_->SetVisible(is_casting_);
}
}
| 0 |
linux | 999653786df6954a31044528ac3f7a5dadca08f4 | NOT_APPLICABLE | NOT_APPLICABLE | mask_from_posix(unsigned short perm, unsigned int flags)
{
int mask = NFS4_ANYONE_MODE;
if (flags & NFS4_ACL_OWNER)
mask |= NFS4_OWNER_MODE;
if (perm & ACL_READ)
mask |= NFS4_READ_MODE;
if (perm & ACL_WRITE)
mask |= NFS4_WRITE_MODE;
if ((perm & ACL_WRITE) && (flags & NFS4_ACL_DIR))
mask |= NFS4_ACE_DELETE_CHILD;
if (perm & ACL_EXECUTE)
mask |= NFS4_EXECUTE_MODE;
return mask;
}
| 0 |
Chrome | a4150b688a754d3d10d2ca385155b1c95d77d6ae | NOT_APPLICABLE | NOT_APPLICABLE | void GLES2DecoderPassthroughImpl::ProcessPendingQueries(bool did_finish) {
ProcessQueries(did_finish);
}
| 0 |
linux | 6ec82562ffc6f297d0de36d65776cff8e5704867 | NOT_APPLICABLE | NOT_APPLICABLE | static int dev_new_index(struct net *net)
{
static int ifindex;
for (;;) {
if (++ifindex <= 0)
ifindex = 1;
if (!__dev_get_by_index(net, ifindex))
return ifindex;
}
}
| 0 |
linux | 0048b4837affd153897ed1222283492070027aa9 | NOT_APPLICABLE | NOT_APPLICABLE | static void blk_mq_queue_exit(struct request_queue *q)
{
percpu_ref_put(&q->mq_usage_counter);
}
| 0 |
openjpeg | 73fdf28342e4594019af26eb6a347a34eceb6296 | NOT_APPLICABLE | NOT_APPLICABLE | opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k)
{
OPJ_UINT32 compno;
OPJ_UINT32 numcomps = p_j2k->m_private_image->numcomps;
opj_tcp_t *l_default_tile;
opj_codestream_info_v2_t* cstr_info = (opj_codestream_info_v2_t*) opj_calloc(1,
sizeof(opj_codestream_info_v2_t));
if (!cstr_info) {
return NULL;
}
cstr_info->nbcomps = p_j2k->m_private_image->numcomps;
cstr_info->tx0 = p_j2k->m_cp.tx0;
cstr_info->ty0 = p_j2k->m_cp.ty0;
cstr_info->tdx = p_j2k->m_cp.tdx;
cstr_info->tdy = p_j2k->m_cp.tdy;
cstr_info->tw = p_j2k->m_cp.tw;
cstr_info->th = p_j2k->m_cp.th;
cstr_info->tile_info = NULL; /* Not fill from the main header*/
l_default_tile = p_j2k->m_specific_param.m_decoder.m_default_tcp;
cstr_info->m_default_tile_info.csty = l_default_tile->csty;
cstr_info->m_default_tile_info.prg = l_default_tile->prg;
cstr_info->m_default_tile_info.numlayers = l_default_tile->numlayers;
cstr_info->m_default_tile_info.mct = l_default_tile->mct;
cstr_info->m_default_tile_info.tccp_info = (opj_tccp_info_t*) opj_calloc(
cstr_info->nbcomps, sizeof(opj_tccp_info_t));
if (!cstr_info->m_default_tile_info.tccp_info) {
opj_destroy_cstr_info(&cstr_info);
return NULL;
}
for (compno = 0; compno < numcomps; compno++) {
opj_tccp_t *l_tccp = &(l_default_tile->tccps[compno]);
opj_tccp_info_t *l_tccp_info = &
(cstr_info->m_default_tile_info.tccp_info[compno]);
OPJ_INT32 bandno, numbands;
/* coding style*/
l_tccp_info->csty = l_tccp->csty;
l_tccp_info->numresolutions = l_tccp->numresolutions;
l_tccp_info->cblkw = l_tccp->cblkw;
l_tccp_info->cblkh = l_tccp->cblkh;
l_tccp_info->cblksty = l_tccp->cblksty;
l_tccp_info->qmfbid = l_tccp->qmfbid;
if (l_tccp->numresolutions < OPJ_J2K_MAXRLVLS) {
memcpy(l_tccp_info->prch, l_tccp->prch, l_tccp->numresolutions);
memcpy(l_tccp_info->prcw, l_tccp->prcw, l_tccp->numresolutions);
}
/* quantization style*/
l_tccp_info->qntsty = l_tccp->qntsty;
l_tccp_info->numgbits = l_tccp->numgbits;
numbands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 :
(OPJ_INT32)l_tccp->numresolutions * 3 - 2;
if (numbands < OPJ_J2K_MAXBANDS) {
for (bandno = 0; bandno < numbands; bandno++) {
l_tccp_info->stepsizes_mant[bandno] = (OPJ_UINT32)
l_tccp->stepsizes[bandno].mant;
l_tccp_info->stepsizes_expn[bandno] = (OPJ_UINT32)
l_tccp->stepsizes[bandno].expn;
}
}
/* RGN value*/
l_tccp_info->roishift = l_tccp->roishift;
}
return cstr_info;
} | 0 |
Chrome | 4c8b008f055f79e622344627fed7f820375a4f01 | NOT_APPLICABLE | NOT_APPLICABLE | void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer)
{
ASSERT(!m_visibilityObservers.contains(observer));
m_visibilityObservers.add(observer);
}
| 0 |
qemu | 3c99afc779c2c78718a565ad8c5e98de7c2c7484 | NOT_APPLICABLE | NOT_APPLICABLE | static void vmxnet3_process_tx_queue(VMXNET3State *s, int qidx)
{
struct Vmxnet3_TxDesc txd;
uint32_t txd_idx;
uint32_t data_len;
hwaddr data_pa;
for (;;) {
if (!vmxnet3_pop_next_tx_descr(s, qidx, &txd, &txd_idx)) {
break;
}
vmxnet3_dump_tx_descr(&txd);
if (!s->skip_current_tx_pkt) {
data_len = (txd.len > 0) ? txd.len : VMXNET3_MAX_TX_BUF_SIZE;
data_pa = le64_to_cpu(txd.addr);
if (!vmxnet_tx_pkt_add_raw_fragment(s->tx_pkt,
data_pa,
data_len)) {
s->skip_current_tx_pkt = true;
}
}
if (s->tx_sop) {
vmxnet3_tx_retrieve_metadata(s, &txd);
s->tx_sop = false;
}
if (txd.eop) {
if (!s->skip_current_tx_pkt) {
vmxnet_tx_pkt_parse(s->tx_pkt);
if (s->needs_vlan) {
vmxnet_tx_pkt_setup_vlan_header(s->tx_pkt, s->tci);
}
vmxnet3_send_packet(s, qidx);
} else {
vmxnet3_on_tx_done_update_stats(s, qidx,
VMXNET3_PKT_STATUS_ERROR);
}
vmxnet3_complete_packet(s, qidx, txd_idx);
s->tx_sop = true;
s->skip_current_tx_pkt = false;
vmxnet_tx_pkt_reset(s->tx_pkt);
}
}
}
| 0 |
ovs | 65c61b0c23a0d474696d7b1cea522a5016a8aeb3 | NOT_APPLICABLE | NOT_APPLICABLE | ofpacts_parse_actions(const char *s, const struct ofpact_parse_params *pp)
{
return ofpacts_parse_copy(s, pp, false, 0);
} | 0 |
ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | NOT_APPLICABLE | NOT_APPLICABLE | set_colors(int fg, int bg)
{
int pair = mypair(fg, bg);
if (pair > 0) {
attron(COLOR_PAIR(mypair(fg, bg)));
}
} | 0 |
redis | 24cc0b984d4ed5045c6ff125b0e619b6ce5ea9c6 | NOT_APPLICABLE | NOT_APPLICABLE | sds sdstrim(sds s, const char *cset) {
char *end, *sp, *ep;
size_t len;
sp = s;
ep = end = s+sdslen(s)-1;
while(sp <= end && strchr(cset, *sp)) sp++;
while(ep > sp && strchr(cset, *ep)) ep--;
len = (sp > ep) ? 0 : ((ep-sp)+1);
if (s != sp) memmove(s, sp, len);
s[len] = '\0';
sdssetlen(s,len);
return s;
} | 0 |
Chrome | bf6a6765d44b09c64b8c75d749efb84742a250e7 | NOT_APPLICABLE | NOT_APPLICABLE | std::string GetDocumentMetadata(FPDF_DOCUMENT doc, const std::string& key) {
size_t size = FPDF_GetMetaText(doc, key.c_str(), nullptr, 0);
if (size == 0)
return std::string();
base::string16 value;
PDFiumAPIStringBufferSizeInBytesAdapter<base::string16> string_adapter(
&value, size, false);
string_adapter.Close(
FPDF_GetMetaText(doc, key.c_str(), string_adapter.GetData(), size));
return base::UTF16ToUTF8(value);
}
| 0 |
server | 2e7891080667c59ac80f788eef4d59d447595772 | NOT_APPLICABLE | NOT_APPLICABLE | virtual bool register_field_in_write_map(void *arg) { return 0; } | 0 |
Chrome | c3957448cfc6e299165196a33cd954b790875fdb | NOT_APPLICABLE | NOT_APPLICABLE | const AtomicString& Document::vlinkColor() const {
return BodyAttributeValue(kVlinkAttr);
}
| 0 |
linux | d846f71195d57b0bbb143382647c2c6638b04c5a | NOT_APPLICABLE | NOT_APPLICABLE | find_table_lock(struct net *net, const char *name, int *error,
struct mutex *mutex)
{
return find_inlist_lock(&net->xt.tables[NFPROTO_BRIDGE], name,
"ebtable_", error, mutex);
}
| 0 |
clutter | e310c68d7b38d521e341f4e8a36f54303079d74e | NOT_APPLICABLE | NOT_APPLICABLE | relate_slaves (gpointer key,
gpointer value,
gpointer data)
{
ClutterDeviceManagerXI2 *manager_xi2 = data;
ClutterInputDevice *master, *slave;
slave = g_hash_table_lookup (manager_xi2->devices_by_id, key);
master = g_hash_table_lookup (manager_xi2->devices_by_id, value);
_clutter_input_device_set_associated_device (slave, master);
_clutter_input_device_add_slave (master, slave);
} | 0 |
linux | f6d8bd051c391c1c0458a30b2a7abcd939329259 | NOT_APPLICABLE | NOT_APPLICABLE | static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
{
/* Charge it to the socket. */
if (ip_queue_rcv_skb(sk, skb) < 0) {
kfree_skb(skb);
return NET_RX_DROP;
}
return NET_RX_SUCCESS;
}
| 0 |
linux | 9842df62004f366b9fed2423e24df10542ee0dc5 | NOT_APPLICABLE | NOT_APPLICABLE | static int fixed_mtrr_seg_end_range_index(int seg)
{
struct fixed_mtrr_segment *mtrr_seg = &fixed_seg_table[seg];
int n;
n = (mtrr_seg->end - mtrr_seg->start) >> mtrr_seg->range_shift;
return mtrr_seg->range_start + n - 1;
}
| 0 |
poppler | b224e2f5739fe61de9fa69955d016725b2a4b78d | NOT_APPLICABLE | NOT_APPLICABLE | void SplashOutputDev::type3D1(GfxState *state, double wx, double wy,
double llx, double lly, double urx, double ury) {
T3FontCache *t3Font;
SplashColor color;
double xt, yt, xMin, xMax, yMin, yMax, x1, y1;
int i, j;
// ignore multiple d0/d1 operators
if (!t3GlyphStack || t3GlyphStack->haveDx) {
return;
}
t3GlyphStack->haveDx = true;
// don't cache if we got a gsave/grestore before the d1
if (t3GlyphStack->doNotCache) {
return;
}
if (unlikely(t3GlyphStack == nullptr)) {
error(errSyntaxWarning, -1, "t3GlyphStack was null in SplashOutputDev::type3D1");
return;
}
if (unlikely(t3GlyphStack->origBitmap != nullptr)) {
error(errSyntaxWarning, -1, "t3GlyphStack origBitmap was not null in SplashOutputDev::type3D1");
return;
}
if (unlikely(t3GlyphStack->origSplash != nullptr)) {
error(errSyntaxWarning, -1, "t3GlyphStack origSplash was not null in SplashOutputDev::type3D1");
return;
}
t3Font = t3GlyphStack->cache;
// check for a valid bbox
state->transform(0, 0, &xt, &yt);
state->transform(llx, lly, &x1, &y1);
xMin = xMax = x1;
yMin = yMax = y1;
state->transform(llx, ury, &x1, &y1);
if (x1 < xMin) {
xMin = x1;
} else if (x1 > xMax) {
xMax = x1;
}
if (y1 < yMin) {
yMin = y1;
} else if (y1 > yMax) {
yMax = y1;
}
state->transform(urx, lly, &x1, &y1);
if (x1 < xMin) {
xMin = x1;
} else if (x1 > xMax) {
xMax = x1;
}
if (y1 < yMin) {
yMin = y1;
} else if (y1 > yMax) {
yMax = y1;
}
state->transform(urx, ury, &x1, &y1);
if (x1 < xMin) {
xMin = x1;
} else if (x1 > xMax) {
xMax = x1;
}
if (y1 < yMin) {
yMin = y1;
} else if (y1 > yMax) {
yMax = y1;
}
if (xMin - xt < t3Font->glyphX ||
yMin - yt < t3Font->glyphY ||
xMax - xt > t3Font->glyphX + t3Font->glyphW ||
yMax - yt > t3Font->glyphY + t3Font->glyphH) {
if (t3Font->validBBox) {
error(errSyntaxWarning, -1, "Bad bounding box in Type 3 glyph");
}
return;
}
if (t3Font->cacheTags == nullptr)
return;
// allocate a cache entry
i = (t3GlyphStack->code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc;
for (j = 0; j < t3Font->cacheAssoc; ++j) {
if ((t3Font->cacheTags[i+j].mru & 0x7fff) == t3Font->cacheAssoc - 1) {
t3Font->cacheTags[i+j].mru = 0x8000;
t3Font->cacheTags[i+j].code = t3GlyphStack->code;
t3GlyphStack->cacheTag = &t3Font->cacheTags[i+j];
t3GlyphStack->cacheData = t3Font->cacheData + (i+j) * t3Font->glyphSize;
} else {
++t3Font->cacheTags[i+j].mru;
}
}
// save state
t3GlyphStack->origBitmap = bitmap;
t3GlyphStack->origSplash = splash;
const double *ctm = state->getCTM();
t3GlyphStack->origCTM4 = ctm[4];
t3GlyphStack->origCTM5 = ctm[5];
// create the temporary bitmap
if (colorMode == splashModeMono1) {
bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
splashModeMono1, false);
splash = new Splash(bitmap, false,
t3GlyphStack->origSplash->getScreen());
color[0] = 0;
splash->clear(color);
color[0] = 0xff;
} else {
bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
splashModeMono8, false);
splash = new Splash(bitmap, vectorAntialias,
t3GlyphStack->origSplash->getScreen());
color[0] = 0x00;
splash->clear(color);
color[0] = 0xff;
}
splash->setMinLineWidth(s_minLineWidth);
splash->setThinLineMode(splashThinLineDefault);
splash->setFillPattern(new SplashSolidColor(color));
splash->setStrokePattern(new SplashSolidColor(color));
//~ this should copy other state from t3GlyphStack->origSplash?
state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3],
-t3Font->glyphX, -t3Font->glyphY);
updateCTM(state, 0, 0, 0, 0, 0, 0);
++nestCount;
} | 0 |
linux | b9a41d21dceadf8104812626ef85dc56ee8a60ed | NOT_APPLICABLE | NOT_APPLICABLE | static void free_io(struct mapped_device *md, struct dm_io *io)
{
mempool_free(io, md->io_pool);
}
| 0 |
mupdf | b2e7d38e845c7d4922d05e6e41f3a2dc1bc1b14a | NOT_APPLICABLE | NOT_APPLICABLE | static void pdf_run_s(fz_context *ctx, pdf_processor *proc)
{
pdf_run_processor *pr = (pdf_run_processor *)proc;
pdf_show_path(ctx, pr, 1, 0, 1, 0);
} | 0 |
libxkbcommon | c1e5ac16e77a21f87bdf3bc4dea61b037a17dddb | NOT_APPLICABLE | NOT_APPLICABLE | ExprCreateAction(xkb_atom_t name, ExprDef *args)
{
EXPR_CREATE(ExprAction, expr, EXPR_ACTION_DECL, EXPR_TYPE_UNKNOWN);
expr->action.name = name;
expr->action.args = args;
return expr;
}
| 0 |
linux | 32452a3eb8b64e01e2be717f518c0be046975b9d | NOT_APPLICABLE | NOT_APPLICABLE | static void io_req_task_queue_fail(struct io_kiocb *req, int ret)
{
req->result = ret;
req->io_task_work.func = io_req_task_cancel;
io_req_task_work_add(req, false);
} | 0 |
php-src | b2af4e8868726a040234de113436c6e4f6372d17 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_FUNCTION(serialize)
{
zval *struc;
php_serialize_data_t var_hash;
smart_str buf = {0};
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &struc) == FAILURE) {
return;
}
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, struc, &var_hash);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
if (EG(exception)) {
smart_str_free(&buf);
RETURN_FALSE;
}
if (buf.s) {
RETURN_NEW_STR(buf.s);
} else {
RETURN_NULL();
}
}
| 0 |
miniupnp | cb8a02af7a5677cf608e86d57ab04241cf34e24f | NOT_APPLICABLE | NOT_APPLICABLE | static const char* inet_n46top(const struct in6_addr* in,
char* buf, size_t buf_len)
{
if (IN6_IS_ADDR_V4MAPPED(in)) {
return inet_ntop(AF_INET, ((uint32_t*)(in->s6_addr))+3, buf, buf_len);
} else {
return inet_ntop(AF_INET6, in, buf, buf_len);
}
}
| 0 |
linux | c70422f760c120480fee4de6c38804c72aa26bc1 | NOT_APPLICABLE | NOT_APPLICABLE | void svc_rdma_unmap_dma(struct svc_rdma_op_ctxt *ctxt)
{
struct svcxprt_rdma *xprt = ctxt->xprt;
struct ib_device *device = xprt->sc_cm_id->device;
u32 lkey = xprt->sc_pd->local_dma_lkey;
unsigned int i;
for (i = 0; i < ctxt->mapped_sges; i++) {
/*
* Unmap the DMA addr in the SGE if the lkey matches
* the local_dma_lkey, otherwise, ignore it since it is
* an FRMR lkey and will be unmapped later when the
* last WR that uses it completes.
*/
if (ctxt->sge[i].lkey == lkey)
ib_dma_unmap_page(device,
ctxt->sge[i].addr,
ctxt->sge[i].length,
ctxt->direction);
}
ctxt->mapped_sges = 0;
}
| 0 |
linux | 704620afc70cf47abb9d6a1a57f3825d2bca49cf | NOT_APPLICABLE | NOT_APPLICABLE | int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
{
struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
struct usb_port *port_dev = hub->ports[udev->portnum - 1];
int port1 = udev->portnum;
int status;
bool really_suspend = true;
usb_lock_port(port_dev);
/* enable remote wakeup when appropriate; this lets the device
* wake up the upstream hub (including maybe the root hub).
*
* NOTE: OTG devices may issue remote wakeup (or SRP) even when
* we don't explicitly enable it here.
*/
if (udev->do_remote_wakeup) {
status = usb_enable_remote_wakeup(udev);
if (status) {
dev_dbg(&udev->dev, "won't remote wakeup, status %d\n",
status);
/* bail if autosuspend is requested */
if (PMSG_IS_AUTO(msg))
goto err_wakeup;
}
}
/* disable USB2 hardware LPM */
if (udev->usb2_hw_lpm_enabled == 1)
usb_set_usb2_hardware_lpm(udev, 0);
if (usb_disable_ltm(udev)) {
dev_err(&udev->dev, "Failed to disable LTM before suspend\n");
status = -ENOMEM;
if (PMSG_IS_AUTO(msg))
goto err_ltm;
}
/* see 7.1.7.6 */
if (hub_is_superspeed(hub->hdev))
status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3);
/*
* For system suspend, we do not need to enable the suspend feature
* on individual USB-2 ports. The devices will automatically go
* into suspend a few ms after the root hub stops sending packets.
* The USB 2.0 spec calls this "global suspend".
*
* However, many USB hubs have a bug: They don't relay wakeup requests
* from a downstream port if the port's suspend feature isn't on.
* Therefore we will turn on the suspend feature if udev or any of its
* descendants is enabled for remote wakeup.
*/
else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0)
status = set_port_feature(hub->hdev, port1,
USB_PORT_FEAT_SUSPEND);
else {
really_suspend = false;
status = 0;
}
if (status) {
dev_dbg(&port_dev->dev, "can't suspend, status %d\n", status);
/* Try to enable USB3 LTM again */
usb_enable_ltm(udev);
err_ltm:
/* Try to enable USB2 hardware LPM again */
if (udev->usb2_hw_lpm_capable == 1)
usb_set_usb2_hardware_lpm(udev, 1);
if (udev->do_remote_wakeup)
(void) usb_disable_remote_wakeup(udev);
err_wakeup:
/* System sleep transitions should never fail */
if (!PMSG_IS_AUTO(msg))
status = 0;
} else {
dev_dbg(&udev->dev, "usb %ssuspend, wakeup %d\n",
(PMSG_IS_AUTO(msg) ? "auto-" : ""),
udev->do_remote_wakeup);
if (really_suspend) {
udev->port_is_suspended = 1;
/* device has up to 10 msec to fully suspend */
msleep(10);
}
usb_set_device_state(udev, USB_STATE_SUSPENDED);
}
if (status == 0 && !udev->do_remote_wakeup && udev->persist_enabled
&& test_and_clear_bit(port1, hub->child_usage_bits))
pm_runtime_put_sync(&port_dev->dev);
usb_mark_last_busy(hub->hdev);
usb_unlock_port(port_dev);
return status;
}
| 0 |
linux | bc0bdc5afaa740d782fbf936aaeebd65e5c2921d | NOT_APPLICABLE | NOT_APPLICABLE | struct rdma_cm_id *rdma_res_to_id(struct rdma_restrack_entry *res)
{
struct rdma_id_private *id_priv =
container_of(res, struct rdma_id_private, res);
return &id_priv->id;
} | 0 |
envoy | 2c60632d41555ec8b3d9ef5246242be637a2db0f | NOT_APPLICABLE | NOT_APPLICABLE | int HeaderMapWrapper::luaReplace(lua_State* state) {
checkModifiable(state);
const char* key = luaL_checkstring(state, 2);
const char* value = luaL_checkstring(state, 3);
const Http::LowerCaseString lower_key(key);
headers_.setCopy(lower_key, value);
return 0;
} | 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | template<typename tc>
CImg<T>& draw_gaussian(const float xc, const float sigma,
const tc *const color, const float opacity=1) {
if (is_empty()) return *this;
if (!color)
throw CImgArgumentException(_cimg_instance
"draw_gaussian(): Specified color is (null).",
cimg_instance);
const float sigma2 = 2*sigma*sigma, nopacity = cimg::abs(opacity), copacity = 1 - std::max(opacity,0.f);
const ulongT whd = (ulongT)_width*_height*_depth;
const tc *col = color;
cimg_forX(*this,x) {
const float dx = (x - xc), val = (float)std::exp(-dx*dx/sigma2);
T *ptrd = data(x,0,0,0);
if (opacity>=1) cimg_forC(*this,c) { *ptrd = (T)(val*(*col++)); ptrd+=whd; }
else cimg_forC(*this,c) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whd; }
col-=_spectrum;
}
return *this; | 0 |
tartarus | 4ff22863d895cb7ebfced4cf923a012a614adaa8 | NOT_APPLICABLE | NOT_APPLICABLE | static unsigned int ssh_tty_parse_specchar(char *s)
{
unsigned int ret;
if (*s) {
char *next = NULL;
ret = ctrlparse(s, &next);
if (!next) ret = s[0];
} else {
ret = 255; /* special value meaning "don't set" */
}
return ret;
}
| 0 |
bitlbee | 30d598ce7cd3f136ee9d7097f39fa9818a272441 | NOT_APPLICABLE | NOT_APPLICABLE | static gboolean prpl_xfer_write(struct file_transfer *ft, char *buffer, unsigned int len)
{
struct prpl_xfer_data *px = ft->data;
if (write(px->fd, buffer, len) != len) {
imcb_file_canceled(px->ic, ft, "Error while writing temporary file");
return FALSE;
}
if (lseek(px->fd, 0, SEEK_CUR) >= ft->file_size) {
close(px->fd);
px->fd = -1;
purple_transfer_forward(ft);
imcb_file_finished(px->ic, ft);
px->ft = NULL;
} else {
px->timeout = b_timeout_add(0, purple_transfer_request_cb, ft);
}
return TRUE;
}
| 0 |
linux | 4a1d704194a441bf83c636004a479e01360ec850 | NOT_APPLICABLE | NOT_APPLICABLE | static unsigned long unmap_page_range(struct mmu_gather *tlb,
struct vm_area_struct *vma,
unsigned long addr, unsigned long end,
struct zap_details *details)
{
pgd_t *pgd;
unsigned long next;
if (details && !details->check_mapping && !details->nonlinear_vma)
details = NULL;
BUG_ON(addr >= end);
mem_cgroup_uncharge_start();
tlb_start_vma(tlb, vma);
pgd = pgd_offset(vma->vm_mm, addr);
do {
next = pgd_addr_end(addr, end);
if (pgd_none_or_clear_bad(pgd))
continue;
next = zap_pud_range(tlb, vma, pgd, addr, next, details);
} while (pgd++, addr = next, addr != end);
tlb_end_vma(tlb, vma);
mem_cgroup_uncharge_end();
return addr;
}
| 0 |
Chrome | 0749ec24fae74ec32d0567eef0e5ec43c84dbcb9 | NOT_APPLICABLE | NOT_APPLICABLE | int FreeList::bucketIndexForSize(size_t size) {
ASSERT(size > 0);
int index = -1;
while (size) {
size >>= 1;
index++;
}
return index;
}
| 0 |
linux | fd4d9c7d0c71866ec0c2825189ebd2ce35bd95b8 | NOT_APPLICABLE | NOT_APPLICABLE | static inline void stat(const struct kmem_cache *s, enum stat_item si)
{
#ifdef CONFIG_SLUB_STATS
/*
* The rmw is racy on a preemptible kernel but this is acceptable, so
* avoid this_cpu_add()'s irq-disable overhead.
*/
raw_cpu_inc(s->cpu_slab->stat[si]);
#endif
} | 0 |
Chrome | e89cfcb9090e8c98129ae9160c513f504db74599 | NOT_APPLICABLE | NOT_APPLICABLE | LocationBar* BrowserView::GetLocationBar() const {
return GetLocationBarView();
}
| 0 |
Chrome | faaa2fd0a05f1622d9a8806da118d4f3b602e707 | NOT_APPLICABLE | NOT_APPLICABLE | void HTMLMediaElement::selectedVideoTrackChanged(VideoTrack* track) {
BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this
<< ") selectedTrackId="
<< (track->selected() ? String(track->id()) : "none");
DCHECK(mediaTracksEnabledInternally());
if (track->selected())
videoTracks().trackSelected(track->id());
videoTracks().scheduleChangeEvent();
if (m_mediaSource)
m_mediaSource->onTrackChanged(track);
WebMediaPlayer::TrackId id = track->id();
webMediaPlayer()->selectedVideoTrackChanged(track->selected() ? &id
: nullptr);
}
| 0 |
Subsets and Splits