[8348] in Athena Bugs

home help back first fref pref prev next nref lref last post

patch for /source/athena/athena.bin/turnin/clients/dump.c

daemon@ATHENA.MIT.EDU (brlewis@Athena.MIT.EDU)
Mon Oct 7 11:26:46 1991

From: brlewis@Athena.MIT.EDU
Date: Mon, 7 Oct 91 11:27:31 -0400
To: bugs@Athena.MIT.EDU

This fixes two bugs:
	1.  Errors from prep_paper were being ignored
	2.  Allocated memory was not freed after an error or empty list

*** dump.c~	Mon Oct  7 11:15:46 1991
--- dump.c	Mon Oct  7 11:20:13 1991
***************
*** 74,80 ****
    if (count == 0) {
      if (verbose)
        empty_list(criterion);
!     return(0L);
    }
  
    /******** main loop through list ********/
--- 74,80 ----
    if (count == 0) {
      if (verbose)
        empty_list(criterion);
!     goto DUMP_CLEANUP;
    }
  
    /******** main loop through list ********/
***************
*** 84,90 ****
      if (paperv[i]->modified.tv_sec < criterion->created.tv_sec ||
          paperv[i]->modified.tv_sec > criterion->modified.tv_sec) continue;
  
!     prep_paper(paperv[i], filename, flags);
      /*** change spaces to underscores ***/
      for (s=filename; *s != '\0'; s++)
        if (isspace(*s)) *s = '_';
--- 84,92 ----
      if (paperv[i]->modified.tv_sec < criterion->created.tv_sec ||
          paperv[i]->modified.tv_sec > criterion->modified.tv_sec) continue;
  
!     /*** do things particular to pickup or collect ***/
!     if (code=prep_paper(paperv[i], filename, flags)) goto DUMP_CLEANUP;
! 
      /*** change spaces to underscores ***/
      for (s=filename; *s != '\0'; s++)
        if (isspace(*s)) *s = '_';
***************
*** 99,105 ****
  	if (rename(filename, newfilename)) {
  	  sprintf(fxmain_error_context, "renaming %s to %s",
  		  filename, newfilename);
! 	  return((long) errno);
  	}
        }
      }
--- 101,108 ----
  	if (rename(filename, newfilename)) {
  	  sprintf(fxmain_error_context, "renaming %s to %s",
  		  filename, newfilename);
! 	  code = (long) errno;
! 	  goto DUMP_CLEANUP;
  	}
        }
      }
***************
*** 116,122 ****
        code = fx_retrieve_file(fxp, paperv[i], filename);
        if (code) {
  	sprintf(fxmain_error_context, "while retrieving \"%s\"", filename);
! 	return(code);
        }
  
        if (!(flags & PRESERVE)) mark_retrieved(fxp, paperv[i]);
--- 119,125 ----
        code = fx_retrieve_file(fxp, paperv[i], filename);
        if (code) {
  	sprintf(fxmain_error_context, "while retrieving \"%s\"", filename);
! 	goto DUMP_CLEANUP;
        }
  
        if (!(flags & PRESERVE)) mark_retrieved(fxp, paperv[i]);
***************
*** 131,138 ****
    }
  
  
! /******** clean up ********/
    fx_list_destroy(&plist);
    free((char *) paperv);
!   return(0L);
  }
--- 134,141 ----
    }
  
  
!  DUMP_CLEANUP:
    fx_list_destroy(&plist);
    free((char *) paperv);
!   return(code);
  }

home help back first fref pref prev next nref lref last post