summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp1
-rw-r--r--noncore/apps/opie-sheet/Excel.cpp4
-rw-r--r--noncore/apps/zsafe/zsafe.cpp57
-rw-r--r--noncore/comm/keypebble/vncauth.c6
-rw-r--r--noncore/net/ftplib/ftplib.c4
-rw-r--r--noncore/todayplugins/stockticker/libstocks/csv.c140
-rw-r--r--noncore/todayplugins/stockticker/libstocks/currency.c1
-rw-r--r--noncore/todayplugins/stockticker/libstocks/lists.h1
-rw-r--r--noncore/todayplugins/stockticker/libstocks/stocks.c189
9 files changed, 246 insertions, 157 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
@@ -343,6 +343,7 @@ Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f)
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
@@ -377,7 +377,9 @@ 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
@@ -1768,12 +1768,14 @@ int ZSafe::loadInit(const char* _filename, const char *password)
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++) {
@@ -1788,8 +1790,10 @@ int ZSafe::loadInit(const char* _filename, const char *password)
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;
@@ -1809,6 +1813,7 @@ int ZSafe::loadInit(const char* _filename, const char *password)
count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
#endif
if (count2 == 0) {
+ delete krc2;
return PWERR_DATA;
}
count += count2;
@@ -1829,6 +1834,7 @@ int ZSafe::loadInit(const char* _filename, const char *password)
bufferIndex += 8;
buffer[bufferIndex + 1] = '\0';
} /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */
+ delete krc2;
size -= buffer[size - 1];
lastcount = 0;
@@ -2099,28 +2105,15 @@ int ZSafe::saveInit(const char *_filename, const char *password)
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);
@@ -2130,6 +2123,7 @@ int ZSafe::saveInit(const char *_filename, const char *password)
}
keylength = j;
krc2->rc2_expandkey (key, keylength, 128);
+ delete krc2;
/* First, we make the IV */
for (count2 = 0; count2 < 4; count2++) {
@@ -2188,15 +2182,21 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE])
/* 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)
@@ -2228,6 +2228,7 @@ int ZSafe::saveFinalize(void)
fclose (fd);
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
@@ -94,12 +94,16 @@ vncDecryptPasswdFromFile(char *fname)
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
@@ -1172,7 +1172,11 @@ 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)
{
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
@@ -141,7 +141,11 @@ 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)
@@ -154,7 +158,11 @@ stock *parse_csv_file(char *csv)
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)
@@ -167,11 +175,19 @@ stock *parse_csv_file(char *csv)
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)
@@ -184,7 +200,11 @@ stock *parse_csv_file(char *csv)
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)
@@ -197,7 +217,11 @@ stock *parse_csv_file(char *csv)
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 /
@@ -206,19 +230,35 @@ stock *parse_csv_file(char *csv)
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 )
@@ -247,7 +287,11 @@ 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)
@@ -328,7 +372,13 @@ stock *parse_csv_history_file(char *csv_file)
/* 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);
@@ -344,57 +394,81 @@ stock *parse_csv_history_file(char *csv_file)
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;
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
@@ -52,6 +52,7 @@ libstocks_return_code get_currency_exchange(char *from,
strcat(symbol, "=X");
error = get_stocks(symbol, &data);
+ free(symbol);
if (error)
{
*exchange = 0;
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
@@ -30,6 +30,7 @@
#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
@@ -105,7 +105,7 @@ yahoo_source find_yahoo_source(char *symbol)
if (!test) return YAHOO_US;
}
-
+
/* We suppose now it is a European stock */
return YAHOO_EUROPE;
}
@@ -116,8 +116,8 @@ yahoo_source find_yahoo_source(char *symbol)
/* *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;
@@ -138,14 +138,14 @@ 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;
@@ -164,13 +164,13 @@ 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);
@@ -222,7 +222,7 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas)
{
fprintf(stderr,"Memory allocating error (%s line %d)\n"
,__FILE__, __LINE__);
- exit(1);
+ exit(1);
}
strcpy(tok_ptr, stocks);
@@ -235,77 +235,75 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas)
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);
@@ -314,34 +312,37 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas)
{
/* 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);
}