> > zw> @@ -8953,7 +8954,8 @@ > > zw> const int cwd_len=2048; > > zw> char *cwd=malloc(cwd_len); > > zw> Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); > > zw> - getcwd( cwd, cwd_len ); > > zw> + cwd = getcwd( cwd, cwd_len ); > > zw> + if (NULL == cwd) strcpy(cwd, "unknown"); > > > > this is bug. > > when cwd is NULL, strcpy will cause segfault; > > > > if (! getcwd( cwd, cwd_len ) ) strcpy(cwd, "unknown"); > > is better; > > *gasp* ... *blush* ... Done!
Though technically correct, it is highly unlikely that if the first malloc() failed that the equivalent call inside of getcwd() for the same length is going to succeed. If malloc() fails for a sane size, it's usually pretty much time to call it a day. I would propose: if(!cwd) return JIM_ERROR; Because the call to Jim_AppendStrings() right after isn't going to be very happy with a NULL cwd. *or* just change cwd to stack allocated and be done with it. --Chris _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development