author | erik <erik> | 2007-01-24 19:46:19 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 19:46:19 (UTC) |
commit | a017bf21dd89159052f2f7a3fbc043a24956c08c (patch) (side-by-side diff) | |
tree | 008be2b62ee5487dc55b8a7c7f043c94268f8362 | |
parent | a4a7bd22feb060a80e20c81cded43cc24f5cd423 (diff) | |
download | opie-a017bf21dd89159052f2f7a3fbc043a24956c08c.zip opie-a017bf21dd89159052f2f7a3fbc043a24956c08c.tar.gz opie-a017bf21dd89159052f2f7a3fbc043a24956c08c.tar.bz2 |
Every file in this commit has a memory leak of some kind or another. I think
all of them are minor and should not effect properly running code. But if I
were you I would give libstocks and the stockticker plugin in Today a wide
berth. That library is atrocious.
-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/libmpeg3.c | 2 | ||||
-rw-r--r-- | libopie2/opieui/oimageeffect.cpp | 5 | ||||
-rw-r--r-- | library/global.cpp | 30 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/Excel.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 57 | ||||
-rw-r--r-- | noncore/comm/keypebble/vncauth.c | 6 | ||||
-rw-r--r-- | noncore/net/ftplib/ftplib.c | 4 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/csv.c | 140 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/currency.c | 1 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/lists.h | 1 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/stocks.c | 189 | ||||
-rw-r--r-- | rsync/delta.c | 2 |
13 files changed, 270 insertions, 172 deletions
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3.c b/core/multimedia/opieplayer/libmpeg3/libmpeg3.c index acaecf7..c8cd3e2 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3.c +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3.c @@ -42,9 +42,9 @@ int mpeg3_check_sig(char *path) fs = mpeg3_new_fs(path); if(mpeg3io_open_file(fs)) { /* File not found */ - return 0; + return mpeg3_delete_fs(fs); } bits = mpeg3io_read_int32(fs); /* Test header */ diff --git a/libopie2/opieui/oimageeffect.cpp b/libopie2/opieui/oimageeffect.cpp index be47eb2..93719bc 100644 --- a/libopie2/opieui/oimageeffect.cpp +++ b/libopie2/opieui/oimageeffect.cpp @@ -2050,10 +2050,13 @@ void OImageEffect::normalize(QImage &img) intense+=histogram[high]; if(intense > threshold_intensity) break; } - if(low == high) + if(low == high) { + free(histogram); + free(normalize_map); return; // zero span bound + } } // Stretch the histogram to create the normalized image mapping. for(i=0; i <= MaxRGB; i++){ diff --git a/library/global.cpp b/library/global.cpp index 7bdd0b1..1895006 100644 --- a/library/global.cpp +++ b/library/global.cpp @@ -538,14 +538,16 @@ void Global::invoke(const QString &c) QString ap=list[0]; // see if the application is already running // XXX should lock file /tmp/qcop-msg-ap if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { - // If the channel is already register, the app is already running, so show it. - { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } - - //QCopEnvelope e("QPE/System", "notBusy(QString)" ); - //e << ap; - return; + // If the channel is already register, the app is already running, so show it. + { + QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); + } + + //QCopEnvelope e("QPE/System", "notBusy(QString)" ); + //e << ap; + return; } // XXX should unlock file /tmp/qcop-msg-ap //see if it is being started if ( StartingAppList::isStarting( ap ) ) { @@ -553,11 +555,11 @@ void Global::invoke(const QString &c) // some entry is clicked. // Real cause is that ::execute is called twice for document tab. But it would need some larger changes // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there // had the idea that an apploader belongs to the launcher ... - //QCopEnvelope e("QPE/System", "notBusy(QString)" ); - //e << ap; - return; + //QCopEnvelope e("QPE/System", "notBusy(QString)" ); + //e << ap; + return; } #endif @@ -567,13 +569,14 @@ void Global::invoke(const QString &c) QStrList slist; unsigned int j; for ( j = 0; j < list.count(); j++ ) - slist.append( list[j].utf8() ); + slist.append( list[j].utf8() ); const char **args = new const char *[slist.count() + 1]; for ( j = 0; j < slist.count(); j++ ) - args[j] = slist.at(j); + args[j] = slist.at(j); + args[j] = NULL; #if !defined(QT_NO_COP) // an attempt to show a wait... @@ -588,10 +591,10 @@ void Global::invoke(const QString &c) QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; #endif qDebug("libfile = %s", libexe.latin1() ); if ( QFile::exists( libexe ) ) { - qDebug("calling quickexec %s", libexe.latin1() ); - quickexecv( libexe.utf8().data(), (const char **)args ); + qDebug("calling quickexec %s", libexe.latin1() ); + quickexecv( libexe.utf8().data(), (const char **)args ); } else #endif { bool success = false; @@ -646,8 +649,9 @@ void Global::invoke(const QString &c) StartingAppList::add( list[0] ); else QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); } + delete [] args; #endif //QT_NO_QWS_MULTIPROCESS } diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 00141a3..45aa045 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp @@ -342,8 +342,9 @@ Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) anno[ln] = 0; unsigned int pos; fread(&pos,sizeof(pos),1,f); b = new Bkmk(nm,anno,pos); + delete [] anno; } } return b; } diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp index 51fe707..27080e9 100644 --- a/noncore/apps/opie-sheet/Excel.cpp +++ b/noncore/apps/opie-sheet/Excel.cpp @@ -376,9 +376,11 @@ ExcelBREC* ExcelBook::PeekBREC(void) char* ExcelBook::GetDataOfBREC(ExcelBREC* record) { if(record->data==NULL) { - ConvertCharToArray(record,Read(record->position,record->length),record->length); + char* readData = Read(record->position,record->length); + ConvertCharToArray(record,readData,record->length); + delete [] readData; }; return record->data;//new? }; diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index f70f863..9c0c6ce 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp @@ -1767,14 +1767,16 @@ int ZSafe::loadInit(const char* _filename, const char *password) Krc2* krc2 = new Krc2(); fd = fopen (_filename, "rb"); - QFileInfo f (_filename); - load_buffer_length = f.size(); - load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; + QFileInfo f (_filename); + load_buffer_length = f.size(); + load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; - if (fd == NULL) + if (fd == NULL) { + delete krc2; return PWERR_OPEN; + } buffer = (char *)malloc(load_buffer_length); for (j = 0; password[j] != '\0'; j++) { key[j] = password[j]; @@ -1787,10 +1789,12 @@ int ZSafe::loadInit(const char* _filename, const char *password) #else size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); #endif - if (size < 8) + if (size < 8) { + delete krc2; return PWERR_DATA; + } for (count = 0; count < 4; count++) { count2 = count << 1; iv[count] = charbuf[count2] << 8; @@ -1808,8 +1812,9 @@ int ZSafe::loadInit(const char* _filename, const char *password) while (count < 8) { count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); #endif if (count2 == 0) { + delete krc2; return PWERR_DATA; } count += count2; } /* while (count < 8) */ @@ -1828,8 +1833,9 @@ int ZSafe::loadInit(const char* _filename, const char *password) memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); bufferIndex += 8; buffer[bufferIndex + 1] = '\0'; } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ + delete krc2; size -= buffer[size - 1]; lastcount = 0; /* This will point to the starting index */ @@ -2098,30 +2104,17 @@ int ZSafe::saveInit(const char *_filename, const char *password) // int val; int count2; Krc2* krc2 = new Krc2(); - /* first we should check the permissions of the filename */ -/* - if (QFile::exists(_filename)) { - val = checkFile(_filename); - if (val != PWERR_GOOD) - return val; - } else - { - val = creat (_filename, (S_IRUSR | S_IWUSR)); - if (val == -1) - return PWERR_OPEN; - else - close(val); - } -*/ - QFileInfo f (_filename); - save_buffer_length = f.size(); - save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; + QFileInfo f (_filename); + save_buffer_length = f.size(); + save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; fd = fopen (_filename, "wb"); - if (fd == NULL) + if (fd == NULL) { + delete krc2; return PWERR_OPEN; + } buffer = (char*)malloc(save_buffer_length); /* make the key ready */ @@ -2129,8 +2122,9 @@ int ZSafe::saveInit(const char *_filename, const char *password) key[j] = password[j]; } keylength = j; krc2->rc2_expandkey (key, keylength, 128); + delete krc2; /* First, we make the IV */ for (count2 = 0; count2 < 4; count2++) { iv[count2] = rand (); @@ -2187,17 +2181,23 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE]) iv[count3] = plaintext[count3]; /* reset the buffer index */ bufferIndex = 0; - if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; - if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; + if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) { + delete krc2; + return PWERR_DATA; + } + if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) { + delete krc2; + return PWERR_DATA; + } } /*for (count3 = 0; count3 < 5; count3++)*/ } /*if (bufferIndex == 5)*/ /* increment a short, not a byte */ count2 += 2; } /*while (count2 < strlen (buffer))*/ - int ret = PWERR_GOOD; - return ret; + delete krc2; + return PWERR_GOOD; } int ZSafe::saveFinalize(void) { @@ -2227,8 +2227,9 @@ int ZSafe::saveFinalize(void) } fclose (fd); free(buffer); + delete krc2; return retval; } void ZSafe::quitMe () diff --git a/noncore/comm/keypebble/vncauth.c b/noncore/comm/keypebble/vncauth.c index 277d145..7de837a 100644 --- a/noncore/comm/keypebble/vncauth.c +++ b/noncore/comm/keypebble/vncauth.c @@ -93,14 +93,18 @@ vncDecryptPasswdFromFile(char *fname) FILE *fp; int i, ch; unsigned char *passwd = (unsigned char *)malloc(9); - if ((fp = fopen(fname,"r")) == NULL) return NULL; + if ((fp = fopen(fname,"r")) == NULL) { + free(passwd); + return NULL; + } for (i = 0; i < 8; i++) { ch = getc(fp); if (ch == EOF) { fclose(fp); + free(passwd); return NULL; } passwd[i] = ch; } diff --git a/noncore/net/ftplib/ftplib.c b/noncore/net/ftplib/ftplib.c index efcd6f0..addf9d2 100644 --- a/noncore/net/ftplib/ftplib.c +++ b/noncore/net/ftplib/ftplib.c @@ -1171,9 +1171,13 @@ static int FtpXfer(const char *localfile, const char *path, } if (local == NULL) local = (typ == FTPLIB_FILE_WRITE) ? stdin : stdout; if (!FtpAccess(path, typ, mode, nControl, &nData)) + { + if (localfile != NULL) + fclose(local); return 0; + } dbuf = malloc(FTPLIB_BUFSIZ); if (typ == FTPLIB_FILE_WRITE) { while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0) diff --git a/noncore/todayplugins/stockticker/libstocks/csv.c b/noncore/todayplugins/stockticker/libstocks/csv.c index 86d8607..110df7c 100644 --- a/noncore/todayplugins/stockticker/libstocks/csv.c +++ b/noncore/todayplugins/stockticker/libstocks/csv.c @@ -140,9 +140,13 @@ stock *parse_csv_file(char *csv) StockPtr = malloc_stock(); ptr = csv_strtok(line, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } symbol = (char *)malloc(strlen(ptr)+1); if (symbol==NULL) { @@ -153,9 +157,13 @@ stock *parse_csv_file(char *csv) strcpy((char *)(symbol), ptr); StockPtr->Symbol = symbol; ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } name = (char *)malloc(strlen(ptr)+1); if (name==NULL) { @@ -166,13 +174,21 @@ stock *parse_csv_file(char *csv) strcpy((char *)(name), ptr); StockPtr->Name = name; ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->CurrentPrice)); ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } date = (char *)malloc(strlen(ptr)+1); if (date==NULL) { @@ -183,9 +199,13 @@ stock *parse_csv_file(char *csv) strcpy((char *)(date), ptr); StockPtr->Date = date; ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } time = (char *)malloc(strlen(ptr)+1); if (time==NULL) { @@ -196,30 +216,50 @@ stock *parse_csv_file(char *csv) strcpy((char *)(time), ptr); StockPtr->Time = time; ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->Variation)); StockPtr->Pourcentage = 100 * StockPtr->Variation / (StockPtr->CurrentPrice - StockPtr->Variation); StockPtr->LastPrice = StockPtr->CurrentPrice - StockPtr->Variation; ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->OpenPrice)); ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->MaxPrice)); ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->MinPrice)); ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } StockPtr->Volume = atoi(ptr); if( !FirstStockPtr ) { @@ -246,9 +286,13 @@ stock *parse_csv_file(char *csv) StockPtr = malloc_stock(); ptr = csv_strtok(line, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } symbol = (char *)malloc(strlen(ptr)+1); if (symbol==NULL) { @@ -327,9 +371,15 @@ stock *parse_csv_history_file(char *csv_file) StockPtr = malloc_stock(); /* Date */ ptr = strtok(line, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + free_stock(FirstStockPtr); + free_stock(LastStockPtr); + return 0; + } sscanf(ptr,"%d-%3s-%d",&day,smonth,&year); i=0; @@ -343,59 +393,83 @@ stock *parse_csv_history_file(char *csv_file) month = i+1; date = (char *)malloc(DATE_LENGTH); if (date==NULL) - { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); - exit(1); - } + { + fprintf(stderr,"Memory allocating error (%s line %d)\n" + ,__FILE__, __LINE__); + exit(1); + } sprintf(date,"%.2d%.2d%.2d", year, month, day); StockPtr->Date = date; /* Open */ ptr = strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + free_stock(FirstStockPtr); + free_stock(LastStockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->OpenPrice)); /* High */ ptr = strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + free_stock(FirstStockPtr); + free_stock(LastStockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->MaxPrice)); /* Low */ ptr = strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + free_stock(FirstStockPtr); + free_stock(LastStockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->MinPrice)); /* Close */ ptr = strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + free_stock(FirstStockPtr); + free_stock(LastStockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->LastPrice)); /* Volume */ ptr = strtok(NULL, ","); if (!ptr) - /* It seems to be an indice */ - /* No volume for indices */ - StockPtr->Volume = 0; + /* It seems to be an indice */ + /* No volume for indices */ + StockPtr->Volume = 0; else - StockPtr->Volume = atoi(ptr); + StockPtr->Volume = atoi(ptr); if( !FirstStockPtr ) - { - FirstStockPtr = StockPtr; - StockPtr->PreviousStock = 0; - } + { + FirstStockPtr = StockPtr; + StockPtr->PreviousStock = 0; + } StockPtr->NextStock = 0; if (LastStockPtr) - { - LastStockPtr->NextStock = StockPtr; - StockPtr->PreviousStock = LastStockPtr; - } + { + LastStockPtr->NextStock = StockPtr; + StockPtr->PreviousStock = LastStockPtr; + } LastStockPtr = StockPtr; end_line++; diff --git a/noncore/todayplugins/stockticker/libstocks/currency.c b/noncore/todayplugins/stockticker/libstocks/currency.c index 9a08a9d..e0090e2 100644 --- a/noncore/todayplugins/stockticker/libstocks/currency.c +++ b/noncore/todayplugins/stockticker/libstocks/currency.c @@ -51,8 +51,9 @@ libstocks_return_code get_currency_exchange(char *from, strcat(symbol, into); strcat(symbol, "=X"); error = get_stocks(symbol, &data); + free(symbol); if (error) { *exchange = 0; return(error); diff --git a/noncore/todayplugins/stockticker/libstocks/lists.h b/noncore/todayplugins/stockticker/libstocks/lists.h index 0132317..a0eb434 100644 --- a/noncore/todayplugins/stockticker/libstocks/lists.h +++ b/noncore/todayplugins/stockticker/libstocks/lists.h @@ -29,7 +29,8 @@ #include "stocks.h" PUBEXT_LISTS stock *malloc_stock(void); +PUBEXT_LISTS void free_stock(stock*); #endif /* __LISTS_H */ diff --git a/noncore/todayplugins/stockticker/libstocks/stocks.c b/noncore/todayplugins/stockticker/libstocks/stocks.c index eb04ba9..3a26a47 100644 --- a/noncore/todayplugins/stockticker/libstocks/stocks.c +++ b/noncore/todayplugins/stockticker/libstocks/stocks.c @@ -104,9 +104,9 @@ yahoo_source find_yahoo_source(char *symbol) #endif if (!test) return YAHOO_US; } - + /* We suppose now it is a European stock */ return YAHOO_EUROPE; } @@ -115,10 +115,10 @@ yahoo_source find_yahoo_source(char *symbol) /* *stocks points to the stocks to fetch */ /* *stock_datas points to the beginning of the list */ /* count allows to connect to all country servers */ /*****************************************************************************/ -libstocks_return_code download_stocks(char *stocks, - stock **stock_datas, +libstocks_return_code download_stocks(char *stocks, + stock **stock_datas, yahoo_source source) { char *stocks_server=NULL; char *url_beg=NULL; @@ -137,16 +137,16 @@ libstocks_return_code download_stocks(char *stocks, { case YAHOO_US: stocks_server = (char *)yahoo_us_stocks_server; break; - + case YAHOO_EUROPE: stocks_server = (char *)yahoo_eu_stocks_server; break; default: stocks_server = (char *)yahoo_us_stocks_server; break; - + } url_beg = (char *)yahoo_url_beg; url_end = (char *)yahoo_url_end; @@ -163,15 +163,15 @@ libstocks_return_code download_stocks(char *stocks, strcpy(url, url_beg); strcat(url, stocks); strcat(url, url_end); - + error=http_get(url, stocks_server, &data); - + free(url); if (error) return error; - + *stock_datas = parse_csv_file(data); free(data); @@ -221,9 +221,9 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) if(tok_ptr==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); - exit(1); + exit(1); } strcpy(tok_ptr, stocks); while( (symbol = strtok(tok_ptr, "+"))!=0) @@ -234,114 +234,115 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) /* look for "." in the symbol */ source = find_yahoo_source(symbol); switch (source) - { - case YAHOO_US: - - if (us_quotes) - { - lgr_us_quotes = strlen(us_quotes); - lgr_symbol = strlen(symbol); - - us_quotes_temp = malloc(lgr_us_quotes + lgr_symbol +2); - if(us_quotes_temp==NULL) - { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); - exit(1); - } - strcpy(us_quotes_temp, us_quotes); - strcat(us_quotes_temp,"+"); - strcat(us_quotes_temp,symbol); - - free(us_quotes); - us_quotes = us_quotes_temp; - } - else - { - us_quotes = malloc(strlen(symbol)+1); - - if(us_quotes==NULL) - { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); - exit(1); - } - strcpy(us_quotes, symbol); - } - - break; - - case YAHOO_EUROPE: - - if (eu_quotes) - { - lgr_eu_quotes = strlen(eu_quotes); - lgr_symbol = strlen(symbol); - - eu_quotes_temp = malloc(lgr_eu_quotes + lgr_symbol +2); - if(eu_quotes_temp==NULL) - { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); - exit(1); - } - strcpy(eu_quotes_temp, eu_quotes); - strcat(eu_quotes_temp, "+"); - strcat(eu_quotes_temp, symbol); - - free(eu_quotes); - eu_quotes = eu_quotes_temp; - } - else - { - eu_quotes = malloc(strlen(symbol)+1); - if(eu_quotes==NULL) - { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); - exit(1); - } - strcpy(eu_quotes, symbol); - } - break; - } + { + case YAHOO_US: + if (us_quotes) + { + lgr_us_quotes = strlen(us_quotes); + lgr_symbol = strlen(symbol); + + us_quotes_temp = malloc(lgr_us_quotes + lgr_symbol +2); + if(us_quotes_temp==NULL) + { + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); + exit(1); + } + strcpy(us_quotes_temp, us_quotes); + strcat(us_quotes_temp,"+"); + strcat(us_quotes_temp,symbol); + + free(us_quotes); + us_quotes = us_quotes_temp; + } + else + { + us_quotes = malloc(strlen(symbol)+1); + + if(us_quotes==NULL) + { + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); + exit(1); + } + strcpy(us_quotes, symbol); + } + + break; + + case YAHOO_EUROPE: + if (eu_quotes) + { + lgr_eu_quotes = strlen(eu_quotes); + lgr_symbol = strlen(symbol); + + eu_quotes_temp = malloc(lgr_eu_quotes + lgr_symbol +2); + if(eu_quotes_temp==NULL) + { + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); + exit(1); + } + strcpy(eu_quotes_temp, eu_quotes); + strcat(eu_quotes_temp, "+"); + strcat(eu_quotes_temp, symbol); + + free(eu_quotes); + eu_quotes = eu_quotes_temp; + } + else + { + eu_quotes = malloc(strlen(symbol)+1); + if(eu_quotes==NULL) + { + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); + exit(1); + } + strcpy(eu_quotes, symbol); + } + break; + } } free(tok_ptr); if (us_quotes) { /* Gets us quotes */ error = download_stocks(us_quotes, &stocks_tmp, YAHOO_US); + free(us_quotes); if (error) return error; } - + if (eu_quotes) { /* Gets european quotes */ error = download_stocks(eu_quotes, &stocks_getted, YAHOO_EUROPE); + free(eu_quotes); if (error) return error; /* concats lists if needed */ if (stocks_tmp) - { - stocks_tmp2 = stocks_tmp; + { + stocks_tmp2 = stocks_tmp; - while(stocks_tmp2 != NULL) - { - last_stock = stocks_tmp2; - stocks_tmp2 = next_stock(stocks_tmp2); - } + while(stocks_tmp2 != NULL) + { + last_stock = stocks_tmp2; + stocks_tmp2 = next_stock(stocks_tmp2); + } - last_stock->NextStock = stocks_getted; - stocks_getted->PreviousStock = last_stock; + last_stock->NextStock = stocks_getted; + stocks_getted->PreviousStock = last_stock; - } - else (stocks_tmp = stocks_getted); + } + else + (stocks_tmp = stocks_getted); } - *stock_datas = stocks_tmp; - + *stock_datas = stocks_tmp; + return(0); } diff --git a/rsync/delta.c b/rsync/delta.c index 323c079..42f3afb 100644 --- a/rsync/delta.c +++ b/rsync/delta.c @@ -334,15 +334,17 @@ rs_job_t *rs_delta_begin(rs_signature_t *sig) if ((job->block_len = sig->block_len) < 0) { rs_log(RS_LOG_ERR, "unreasonable block_len %d in signature", job->block_len); + rs_job_free(job); return NULL; } job->strong_sum_len = sig->strong_sum_len; if (job->strong_sum_len < 0 || job->strong_sum_len > RS_MD4_LENGTH) { rs_log(RS_LOG_ERR, "unreasonable strong_sum_len %d in signature", job->strong_sum_len); + rs_job_free(job); return NULL; } return job; |