-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/libmpeg3.c | 2 | ||||
-rw-r--r-- | libopie2/opieui/oimageeffect.cpp | 5 | ||||
-rw-r--r-- | library/global.cpp | 6 | ||||
-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 | ||||
-rw-r--r-- | rsync/delta.c | 2 |
13 files changed, 152 insertions, 54 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 @@ -30,33 +30,33 @@ int mpeg3_delete(mpeg3_t *file) mpeg3_delete_fs(file->fs); mpeg3_delete_demuxer(file->demuxer); free(file); } int mpeg3_check_sig(char *path) { mpeg3_fs_t *fs; unsigned int bits; char *ext; int result = 0; 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 */ if(bits == MPEG3_TOC_PREFIX || bits == MPEG3_TOC_PREFIXLOWER) { result = 1; } else if((((bits >> 24) & 0xff) == MPEG3_SYNC_BYTE) || (bits == MPEG3_PACK_START_CODE) || ((bits & 0xfff00000) == 0xfff00000) || (bits == MPEG3_SEQUENCE_START_CODE) || (bits == MPEG3_PICTURE_START_CODE) || (((bits & 0xffff0000) >> 16) == MPEG3_AC3_START_CODE) || ((bits >> 8) == MPEG3_ID3_PREFIX) || 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 @@ -2038,35 +2038,38 @@ void OImageEffect::normalize(QImage &img) if (low == high){ // Unreasonable contrast; use zero threshold to determine boundaries. threshold_intensity=0; intense=0; for(low=0; low < MaxRGB; ++low){ intense+=histogram[low]; if(intense > threshold_intensity) break; } intense=0; for(high=MaxRGB; high != 0; --high) { 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++){ if (i < (int) low) normalize_map[i]=0; else{ if(i > (int) high) normalize_map[i]=MaxRGB; else normalize_map[i]=(MaxRGB-1)*(i-low)/(high-low); } } // Normalize if(img.depth() > 8){ // DirectClass unsigned int *data; for(y=0; y < img.height(); ++y){ diff --git a/library/global.cpp b/library/global.cpp index 7bdd0b1..1895006 100644 --- a/library/global.cpp +++ b/library/global.cpp @@ -527,65 +527,68 @@ void Global::terminate( const AppLnk* app ) \warning Do not use this function. Use execute instead. \sa execute() */ void Global::invoke(const QString &c) { // Convert the command line in to a list of arguments QStringList list = QStringList::split(QRegExp(" *"),c); #if !defined(QT_NO_COP) 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 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 ) ) { // FIXME take it out for now, since it leads to a much to short showing of wait if // 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; } #endif #ifdef QT_NO_QWS_MULTIPROCESS QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); #else QStrList slist; unsigned int j; for ( j = 0; j < list.count(); j++ ) 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] = NULL; #if !defined(QT_NO_COP) // an attempt to show a wait... // more logic should be used, but this will be fine for the moment... QCopEnvelope ( "QPE/System", "busy()" ); #endif #ifdef HAVE_QUICKEXEC #ifdef Q_OS_MACX QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".dylib"; #else QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; #endif qDebug("libfile = %s", libexe.latin1() ); if ( QFile::exists( libexe ) ) { @@ -634,32 +637,33 @@ void Global::invoke(const QString &c) success = false; break; } if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) continue; break; // success } ::close ( pfd [0] ); } } if ( success ) 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 } /*! Executes the application identfied by \a c, passing \a document if it isn't null. Note that a better approach might be to send a QCop message to the application's QPE/Application/\e{appname} channel. */ void Global::execute( const QString &c, const QString& document ) { // ask the server to do the work #if !defined(QT_NO_COP) if ( document.isNull() ) { 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 @@ -330,32 +330,33 @@ Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) Bkmk* b = NULL; if (f != NULL) { unsigned short ln; if (fread(&ln,sizeof(ln),1,f) == 1) { tchar* nm = new tchar[ln+1]; fread(nm,sizeof(tchar),ln,f); nm[ln] = 0; fread(&ln,sizeof(ln),1,f); tchar* anno = new tchar[ln+1]; if (ln > 0) fread(anno,sizeof(tchar),ln,f); anno[ln] = 0; unsigned int pos; fread(&pos,sizeof(pos),1,f); b = new Bkmk(nm,anno,pos); + delete [] anno; } } return b; } Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) { Bkmk* b = NULL; if (f != NULL) { unsigned short ln; if (fread(&ln,sizeof(ln),1,f) == 1) { b = new Bkmk; b->m_namelen = ln; b->m_name = new unsigned char[b->m_namelen]; 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 @@ -364,33 +364,35 @@ ExcelBREC* ExcelBook::GetBREC(void) }; ExcelBREC* ExcelBook::PeekBREC(void) { int oldpos; ExcelBREC* NextRec; oldpos=Position; NextRec=GetBREC(); SeekPosition(oldpos); return NextRec; }; 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? }; void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) { record->data=new char[length]; for(int w1=0;w1<=length-1;w1++) record->data[w1]=chars[w1]; }; bool ExcelSheet::InitCells() { int r; Cells.resize(rows * cols + cols+1); 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 @@ -1759,89 +1759,95 @@ bool ZSafe::openDocument(const char* _filename, const char* ) int ZSafe::loadInit(const char* _filename, const char *password) { unsigned int j = 0; unsigned int keylength=0; int count=0, count2=0, count3=0; unsigned char charbuf[8]; unsigned short ciphertext[4]; char key[128]; 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; - 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]; } keylength = j; krc2->rc2_expandkey (key, keylength, 128); #ifndef Q_WS_WIN size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); #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; iv[count] += charbuf[count2 + 1]; } size = 0; bufferIndex = 0; #ifndef Q_WS_WIN while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { while (count < 8) { count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); #else while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { 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) */ size += 8; for (count2 = 0; count2 < 8; count2 += 2) { count3 = count2 >> 1; ciphertext[count3] = charbuf[count2] << 8; ciphertext[count3] += charbuf[count2 + 1]; plaintext[count3] = ciphertext[count3] ^ iv[count3]; iv[count3] = plaintext[count3]; } /* for (count2) */ krc2->rc2_decrypt (plaintext); 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 */ bufferIndex = 0; return PWERR_GOOD; } int ZSafe::loadEntry(char *entry[FIELD_SIZE]) { /* Strip off PKCS 5 padding * Should check to make sure it's good here */ int count, count1=0; for (count = lastcount; count < size; count++) { @@ -2086,63 +2092,51 @@ void ZSafe::getDocPassword(QString title) } else { exitZs (1); } } int ZSafe::saveInit(const char *_filename, const char *password) { char key[128]; unsigned int j = 0; unsigned int keylength; // 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; 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 */ for (j = 0; password[j] != '\0'; j++) { 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 (); putc ((unsigned char) (iv[count2] >> 8), fd); putc ((unsigned char) (iv[count2] & 0xff), fd); } bufferIndex = 0; return PWERR_GOOD; } int ZSafe::saveEntry(char *entry[FIELD_SIZE]) { char *text1; @@ -2175,72 +2169,79 @@ int ZSafe::saveEntry(char *entry[FIELD_SIZE]) #ifdef WORDS_BIGENDIAN plaintext[bufferIndex] = buffer[count2] << 8; plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; #endif bufferIndex++; if (bufferIndex == 4) { krc2->rc2_encrypt (plaintext); for (count3 = 0; count3 < 4; count3++) { ciphertext[count3] = iv[count3] ^ plaintext[count3]; /* Now store the ciphertext as the iv */ 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) { int count1, retval = PWERR_GOOD; unsigned short ciphertext[4]; Krc2* krc2 = new Krc2(); /* Tack on the PKCS 5 padding * How it works is we fill up the last n bytes with the value n * * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left * over, leaving us 3 short, so we fill it in with 3's. * * If we come out even, we fill it with 8 8s * * um, except that in this instance we are using 4 shorts instead of 8 bytes. * so, half everything */ for (count1 = bufferIndex; count1 < 4; count1++) { plaintext[count1] = (4 - bufferIndex); } krc2->rc2_encrypt (plaintext); for (count1 = 0; count1 < 4; count1++) { ciphertext[count1] = iv[count1] ^ plaintext[count1]; if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; } fclose (fd); free(buffer); + delete krc2; return retval; } void ZSafe::quitMe () { if (modified) { switch( QMessageBox::information( this, tr("ZSafe"), tr("Do you want to save\nbefore exiting?"), tr("&Save"), tr("S&ave with\nnew\npassword"), tr("&Don't Save"), 0 // Enter == button 0 ) ) { // Escape == button 2 case 0: // Save clicked, Alt-S or Enter pressed. 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 @@ -81,38 +81,42 @@ vncEncryptAndStorePasswd(char *passwd, char *fname) } /* * Decrypt a password from a file. Returns a pointer to a newly allocated * string containing the password or a null pointer if the password could * not be retrieved for some reason. */ char * 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; } deskey(fixedkey, DE1); des(passwd, passwd); passwd[8] = 0; return (char *)passwd; } /* * Generate CHALLENGESIZE random bytes for use in challenge-response 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 @@ -1159,33 +1159,37 @@ static int FtpXfer(const char *localfile, const char *path, char ac[4] = "w"; if (typ == FTPLIB_FILE_WRITE) ac[0] = 'r'; if (mode == FTPLIB_IMAGE) ac[1] = 'b'; local = fopen(localfile, ac); if (local == NULL) { strncpy(nControl->response, strerror(errno), sizeof(nControl->response)); return 0; } } 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) if ((c = FtpWrite(dbuf, l, nData)) < l) { printf("short write: passed %d, wrote %d\n", l, c); rv = 0; break; } } else { while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nData)) > 0) if (fwrite(dbuf, 1, l, 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 @@ -128,139 +128,183 @@ stock *parse_csv_file(char *csv) test = line; valid = 0; while ( (test = strstr(test, "N/A")) ) { valid ++; test = test +3; } if (valid < 6) { /* This Symbol is valid */ 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) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } 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) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } 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) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } 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) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } 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 ) { FirstStockPtr = StockPtr; StockPtr->PreviousStock = 0; } StockPtr->NextStock = 0; if (LastStockPtr) { LastStockPtr->NextStock = StockPtr; StockPtr->PreviousStock = LastStockPtr; } LastStockPtr = StockPtr; } else { /* this symbol is not valid */ /* Set the stock struct just with Symbol, all other are NULL */ /* This can be used to see if the symbol has been reached are not */ 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) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } strcpy((char *)(symbol), ptr); StockPtr->Symbol = symbol; if( !FirstStockPtr ) { FirstStockPtr = StockPtr; StockPtr->PreviousStock = 0; } @@ -315,74 +359,104 @@ stock *parse_csv_history_file(char *csv_file) /* do not use the first line */ if (!(end_line = strstr(line, "\n"))) return 0; *end_line = 0; end_line++; line = end_line; while ((end_line = strstr(line, "\n"))) { *end_line = 0; 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; #ifdef __UNIX__ while((test=strcasecmp(months[i], smonth))) i++; #elif __WINDOWS__ while(test=_mbsnbicmp(months[i], smonth, strlen(months[i]))) i++; #endif month = i+1; date = (char *)malloc(DATE_LENGTH); if (date==NULL) { 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; else StockPtr->Volume = atoi(ptr); if( !FirstStockPtr ) { FirstStockPtr = StockPtr; StockPtr->PreviousStock = 0; 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 @@ -39,28 +39,29 @@ libstocks_return_code get_currency_exchange(char *from, char *symbol; stock *data; libstocks_return_code error; if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } strcpy(symbol, from); strcat(symbol, into); strcat(symbol, "=X"); error = get_stocks(symbol, &data); + free(symbol); if (error) { *exchange = 0; return(error); } free_stocks(data); *exchange = data->CurrentPrice; 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 @@ -17,19 +17,20 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef __LISTS_H__ #define __LISTS_H__ #ifndef __LISTS_C__ #define PUBEXT_LISTS extern #else #define PUBEXT_LISTS #endif #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 @@ -224,124 +224,125 @@ libstocks_return_code get_stocks(const char *stocks, stock **stock_datas) ,__FILE__, __LINE__); exit(1); } strcpy(tok_ptr, stocks); while( (symbol = strtok(tok_ptr, "+"))!=0) { /* clear tok_ptr for next strtok */ tok_ptr = NULL; /* 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__); + 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__); + 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__); + 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__); + 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; while(stocks_tmp2 != NULL) { last_stock = stocks_tmp2; stocks_tmp2 = next_stock(stocks_tmp2); } last_stock->NextStock = stocks_getted; stocks_getted->PreviousStock = last_stock; } - else (stocks_tmp = stocks_getted); + else + (stocks_tmp = stocks_getted); } *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 @@ -322,30 +322,32 @@ static rs_result rs_delta_s_header(rs_job_t *job) } /** * Prepare to compute a streaming delta. */ rs_job_t *rs_delta_begin(rs_signature_t *sig) { rs_job_t *job; job = rs_job_new("delta", rs_delta_s_header); job->signature = 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; } |