On Thu, Mar 4, 2010 at 8:44 PM, Enlightenment SVN <no-re...@enlightenment.org> wrote: > Modified: trunk/elmdentica/src/curl.c > =================================================================== > --- trunk/elmdentica/src/curl.c 2010-03-04 22:42:31 UTC (rev 46883) > +++ trunk/elmdentica/src/curl.c 2010-03-04 23:44:34 UTC (rev 46884) > @@ -49,7 +49,8 @@ > > void show_http_error(long response_code, char * method, char * url) { > Evas_Object *box=NULL, *frame1=NULL, *label=NULL, *button=NULL; > - char buf[2100]; > + int res=0; > + char *buf=calloc(2100, sizeof(char)); > > /* Error Window */ > error_win = elm_win_inwin_add(win); > @@ -61,8 +62,13 @@ > > /* First frame (with message) */ > frame1 = elm_frame_add(win); > - g_sprintf(buf, _("%s got a %ld HTTP > Response..."), method, response_code); > - elm_frame_label_set(frame1, buf); > + if(buf) { > + res = asprintf(&buf, _("%s got a %ld > HTTP Response..."), method, response_code); > + if(res != -1) { > + elm_frame_label_set(frame1, > buf); > + } > + free(buf); > + }
Watch out asprintf() usage, see it's man page. by giving asprintf() an allocated buffer, you just lost it's contents... so a leak of 2100 bytes as you previously calloc()ed it! This code should look like: char *buf; int res; /* do NOT set it to zero if you'll set it before first use! */ res = asprintf(&buf, _("%s got an %ld HTTP response..."), method, response_code); if (res > 0) { elm_frame_label_set(frame1, buf); free(buf); } at least you are consistent and make this same error in other places, so you need to fix them all :-) extra notes: - AFAIK there is no reason why response_code should be a long... it's http, it will barely get over 1000. - keep indentation consistent! Your code goes as a cascade, with new indent levels for no obvious reasons... this makes review harder (I was wondering if the buf was the same or not.) BR, -- Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN: barbi...@gmail.com Skype: gsbarbieri Mobile: +55 (19) 9225-2202 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel