~ubuntu-branches/ubuntu/jaunty/clamav/jaunty-backports

« back to all changes in this revision

Viewing changes to libclamav/others_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-10-02 17:11:00 UTC
  • mfrom: (0.3.1 lucid-proposed)
  • Revision ID: james.westby@ubuntu.com-20101002171100-0erjjoucua6kw2pc
Tags: 0.96.3+dfsg-2ubuntu0.10.04.1~jaunty1
* Source backport for Jaunty
  - Change build-dep on libtdl-dev to libtdl7-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
        void *alloc;
145
145
 
146
146
 
147
 
    if(!size || size > CLI_MAX_ALLOCATION) {
148
 
        cli_errmsg("cli_calloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
 
147
    if(!nmemb || !size || size > CLI_MAX_ALLOCATION || nmemb > CLI_MAX_ALLOCATION
 
148
        || (nmemb*size > CLI_MAX_ALLOCATION)) {
 
149
        cli_errmsg("cli_calloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) nmemb*size);
149
150
        return NULL;
150
151
    }
151
152
 
687
688
        err = errno;
688
689
#endif
689
690
        closedir(dd);
 
691
        ret = CL_SUCCESS;
690
692
        if (err) {
691
693
            char errs[128];
692
694
            cli_errmsg("Unable to readdir() directory %s: %s\n", dirname,
693
695
                       cli_strerror(errno, errs, sizeof(errs)));
694
696
            /* report error to callback using error_stat */
695
697
            ret = callback(NULL, NULL, dirname, error_stat, data);
696
 
            if (ret != CL_SUCCESS)
 
698
            if (ret != CL_SUCCESS) {
 
699
                if (entries) {
 
700
                    for (i=0;i<entries_cnt;i++) {
 
701
                        struct dirent_data *entry = &entries[i];
 
702
                        free(entry->filename);
 
703
                        free(entry->statbuf);
 
704
                    }
 
705
                    free(entries);
 
706
                }
697
707
                return ret;
 
708
            }
698
709
        }
699
710
 
700
711
        if (entries) {
712
723
            for (i++;i<entries_cnt;i++) {
713
724
                struct dirent_data *entry = &entries[i];
714
725
                free(entry->filename);
 
726
                free(entry->statbuf);
715
727
            }
716
728
            free(entries);
717
729
        }