Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Segmentation Violation
@ 1996-11-06  5:00 Nader Behzad
  1996-11-06  5:00 ` Ron Natalie
  1996-11-06  5:00 ` Steve Strange USG
  0 siblings, 2 replies; 4+ messages in thread
From: Nader Behzad @ 1996-11-06  5:00 UTC (permalink / raw)





Hi all,

Could anyone tell me if I am doing something wrong here or is it
the compiler:

  char *tempstring;

  tempstring = (char *)Malloc(256*sizeof(char));

  char_count = strlen(angle_file);
  tempstring = strrchr(angle_file, '/');
  if (tempstring != NULL) {
     tempstring++;
  }

  i =  (char_count - strlen(tempstring)); /*  <-------- A  */
  strncpy(temp, angle_file, i);
  temp[i] = '\0';




"tempstring" is NULL and this causes the program to crash at point A.
The strlen result for NULL should be 0 right??
I don't have this problem under SUN_OS or Solaris platforms.

Thank you,
Sincerely,
Nader



--
---------------------------------------------------------------------
|                                                                   | 
| Nader T. Behzad                                                   |
| e-mail: nbehzad@ee.ualberta.ca                                    |
| WWW: http://www.ee.ualberta.ca/~nbehzad                           |
|                                                                   |
|===================================================================|
|                                                                   |
| "Whatever you do will be insignificant, but it is very            |
|  important that you do it." --Mahatma Gandhi                      |
|                                                                   |
---------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1996-11-06  5:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-11-06  5:00 Segmentation Violation Nader Behzad
1996-11-06  5:00 ` Ron Natalie
1996-11-06  5:00 ` Steve Strange USG
1996-11-06  5:00   ` Ron Natalie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox