Skip to content

Commit

Permalink
Mainly the pull request 'Fix unhandled errors of malloc' by Thomas1664
Browse files Browse the repository at this point in the history
  • Loading branch information
untergasser committed Oct 5, 2024
1 parent 010c4e8 commit f8b6706
Show file tree
Hide file tree
Showing 5 changed files with 1,042 additions and 1,008 deletions.
5 changes: 5 additions & 0 deletions src/amplicontm.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ amplicon_result amplicontm(const char *inseq,
int orilen = strlen(inseq);
int gc_count = 0;
ret.seq = (char *) malloc(sizeof(char) * (orilen + 1));
if ((ret.seq == NULL)) {
ret.error = 1;
amp_free_all(alloc_box, alloc_count);
return ret;
}
for (i = 0 ; i < orilen ; i++) {
ret.seq[ret.seq_len]=toupper(inseq[i]);
switch(ret.seq[ret.seq_len]) {
Expand Down
32 changes: 17 additions & 15 deletions src/libprimer3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1167,29 +1167,32 @@ create_seq_arg()

/* Free a seq_arg data structure */
void
destroy_seq_args(seq_args *sa)
destroy_seq_args(seq_args *sa)
{
if (NULL == sa) return;
free(sa->internal_input);
free(sa->left_input);
free(sa->right_input);
free(sa->sequence);

free(sa->quality);
free(sa->sequence);
free(sa->sequence_name);
free(sa->trimmed_seq);

free(sa->overhang_left);
free(sa->overhang_right);
free(sa->overhang_right_rv);

/* edited by T. Koressaar for lowercase masking */
free(sa->trimmed_orig_seq);

free(sa->trimmed_masked_seq_r);

free(sa->trimmed_masked_seq);

free(sa->trimmed_masked_seq_r);

free(sa->upcased_seq);
free(sa->upcased_seq_r);
free(sa->sequence_name);

free(sa->left_input);
free(sa->right_input);
free(sa->internal_input);

free(sa->overhang_left);
free(sa->overhang_right);
free(sa->overhang_right_rv);

free(sa);
}

Expand Down Expand Up @@ -6404,7 +6407,7 @@ destroy_pr_append_str(pr_append_str *str)
int
pr_append_external(pr_append_str *x, const char *s)
{
int xlen, slen;
size_t xlen, slen;

PR_ASSERT(NULL != s);
PR_ASSERT(NULL != x);
Expand Down Expand Up @@ -10014,7 +10017,6 @@ p3_print_args(const p3_global_settings *p, seq_args *s)
printf("quality_storage_size %i\n", s->quality_storage_size) ;
printf("*sequence %s\n", s->sequence) ;
printf("*sequence_name %s\n", s->sequence_name) ;
printf("*sequence_file %s\n", s->sequence_file) ;
printf("*trimmed_seq %s\n", s->trimmed_seq) ;
printf("*trimmed_orig_seq %s\n", s->trimmed_orig_seq) ;
printf("*trimmed_masked_seq %s\n", s->trimmed_masked_seq) ;
Expand Down
3 changes: 1 addition & 2 deletions src/libprimer3.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ typedef enum p3_output_type {

/* pr_append_str is an append-only string ADT. */
typedef struct pr_append_str {
int storage_size;
size_t storage_size;
char *data;
} pr_append_str;

Expand Down Expand Up @@ -867,7 +867,6 @@ typedef struct seq_args {
char *sequence; /* The template sequence itself as input,
not trimmed, not up-cased. */
char *sequence_name; /* An identifier for the sequence. */
char *sequence_file; /* Another identifier for the sequence. */
char *trimmed_seq; /* The included region only, _UPCASED_. */

/* Element add by T. Koressaar support lowercase masking: */
Expand Down
Loading

0 comments on commit f8b6706

Please sign in to comment.