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 /noncore | |
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-- | 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 | 45 | ||||
-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 | 106 | ||||
-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 | 23 |
9 files changed, 140 insertions, 51 deletions
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 @@ -345,2 +345,3 @@ Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) b = new Bkmk(nm,anno,pos); + delete [] anno; } 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 @@ -379,3 +379,5 @@ char* ExcelBook::GetDataOfBREC(ExcelBREC* record) { - ConvertCharToArray(record,Read(record->position,record->length),record->length); + char* readData = Read(record->position,record->length); + ConvertCharToArray(record,readData,record->length); + delete [] readData; }; 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 @@ -1774,4 +1774,6 @@ int ZSafe::loadInit(const char* _filename, const char *password) - if (fd == NULL) + if (fd == NULL) { + delete krc2; return PWERR_OPEN; + } @@ -1790,4 +1792,6 @@ int ZSafe::loadInit(const char* _filename, const char *password) - if (size < 8) + if (size < 8) { + delete krc2; return PWERR_DATA; + } @@ -1811,2 +1815,3 @@ int ZSafe::loadInit(const char* _filename, const char *password) if (count2 == 0) { + delete krc2; return PWERR_DATA; @@ -1831,2 +1836,3 @@ int ZSafe::loadInit(const char* _filename, const char *password) } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ + delete krc2; size -= buffer[size - 1]; @@ -2101,17 +2107,2 @@ int ZSafe::saveInit(const char *_filename, const char *password) - /* 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); @@ -2121,4 +2112,6 @@ int ZSafe::saveInit(const char *_filename, const char *password) fd = fopen (_filename, "wb"); - if (fd == NULL) + if (fd == NULL) { + delete krc2; return PWERR_OPEN; + } @@ -2132,2 +2125,3 @@ int ZSafe::saveInit(const char *_filename, const char *password) krc2->rc2_expandkey (key, keylength, 128); + delete krc2; @@ -2190,4 +2184,10 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE]) 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++)*/ @@ -2197,4 +2197,4 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE]) } /*while (count2 < strlen (buffer))*/ - int ret = PWERR_GOOD; - return ret; + delete krc2; + return PWERR_GOOD; } @@ -2230,2 +2230,3 @@ int ZSafe::saveFinalize(void) free(buffer); + delete krc2; return retval; 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 @@ -96,3 +96,6 @@ vncDecryptPasswdFromFile(char *fname) - if ((fp = fopen(fname,"r")) == NULL) return NULL; + if ((fp = fopen(fname,"r")) == NULL) { + free(passwd); + return NULL; + } @@ -102,2 +105,3 @@ vncDecryptPasswdFromFile(char *fname) fclose(fp); + free(passwd); return NULL; 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 @@ -1174,3 +1174,7 @@ static int FtpXfer(const char *localfile, const char *path, if (!FtpAccess(path, typ, mode, nControl, &nData)) + { + if (localfile != NULL) + fclose(local); return 0; + } dbuf = malloc(FTPLIB_BUFSIZ); 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 @@ -143,3 +143,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(line, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } @@ -156,3 +160,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } @@ -169,3 +177,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->CurrentPrice)); @@ -173,3 +185,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } @@ -186,3 +202,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } @@ -199,3 +219,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->Variation)); @@ -208,3 +232,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->OpenPrice)); @@ -212,3 +240,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->MaxPrice)); @@ -216,3 +248,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } sscanf(ptr,"%f",&(StockPtr->MinPrice)); @@ -220,3 +256,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(NULL, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } StockPtr->Volume = atoi(ptr); @@ -249,3 +289,7 @@ stock *parse_csv_file(char *csv) ptr = csv_strtok(line, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + return 0; + } @@ -330,3 +374,9 @@ stock *parse_csv_history_file(char *csv_file) ptr = strtok(line, ","); - if (!ptr) return 0; + if (!ptr) + { + free_stock(StockPtr); + free_stock(FirstStockPtr); + free_stock(LastStockPtr); + return 0; + } @@ -356,3 +406,9 @@ stock *parse_csv_history_file(char *csv_file) 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)); @@ -361,3 +417,9 @@ stock *parse_csv_history_file(char *csv_file) 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)); @@ -366,3 +428,9 @@ stock *parse_csv_history_file(char *csv_file) 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)); @@ -371,3 +439,9 @@ stock *parse_csv_history_file(char *csv_file) 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)); 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 @@ -54,2 +54,3 @@ libstocks_return_code get_currency_exchange(char *from, error = get_stocks(symbol, &data); + free(symbol); if (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 @@ -32,2 +32,3 @@ PUBEXT_LISTS stock *malloc_stock(void); +PUBEXT_LISTS void free_stock(stock*); 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 @@ -239,3 +239,2 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) case YAHOO_US: - if (us_quotes) @@ -248,4 +247,4 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); exit(1); @@ -265,4 +264,4 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); exit(1); @@ -275,3 +274,2 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) case YAHOO_EUROPE: - if (eu_quotes) @@ -284,4 +282,4 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); exit(1); @@ -300,4 +298,4 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) { - fprintf(stderr,"Memory allocating error (%s line %d)\n" - ,__FILE__, __LINE__); + fprintf(stderr,"Memory allocating error (%s line %d)\n", + __FILE__, __LINE__); exit(1); @@ -316,2 +314,3 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) error = download_stocks(us_quotes, &stocks_tmp, YAHOO_US); + free(us_quotes); if (error) return error; @@ -323,2 +322,3 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) error = download_stocks(eu_quotes, &stocks_getted, YAHOO_EUROPE); + free(eu_quotes); if (error) return error; @@ -340,3 +340,4 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) } - else (stocks_tmp = stocks_getted); + else + (stocks_tmp = stocks_getted); } |