fmt_str was broken. It did not check for out==NULL

master
leitner 23 years ago
parent 1fa408275c
commit b40bae5bf4

@ -1,3 +1,6 @@
0.9:
fmt_str did not check for out==NULL! Thanks, Uwe Ohse.
0.8: 0.8:
BSD compatibility. BSD compatibility.
fix mmap_shared. fix mmap_shared.

@ -4,10 +4,10 @@ unsigned int fmt_str(char *out,const char *in) {
register char* s=out; register char* s=out;
register const char* t=in; register const char* t=in;
for (;;) { for (;;) {
if (!*t) break; *s=*t; ++s; ++t; if (!*t) break; if (s) { *s=*t; ++s; } ++t;
if (!*t) break; *s=*t; ++s; ++t; if (!*t) break; if (s) { *s=*t; ++s; } ++t;
if (!*t) break; *s=*t; ++s; ++t; if (!*t) break; if (s) { *s=*t; ++s; } ++t;
if (!*t) break; *s=*t; ++s; ++t; if (!*t) break; if (s) { *s=*t; ++s; } ++t;
} }
return s-out; return t-in;
} }

5
t.c

@ -14,7 +14,10 @@
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
int main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
#if 1 char buf[100];
printf("%d\n",fmt_str(buf,"fnord"));
printf("%d\n",fmt_str(0,"fnord"));
#if 0
buffer_putulong(buffer_1,23); buffer_putulong(buffer_1,23);
// buffer_putspace(buffer_1); // buffer_putspace(buffer_1);
buffer_putsflush(buffer_1,"\n"); buffer_putsflush(buffer_1,"\n");

Loading…
Cancel
Save