ruby/ruby-1.8.x_yaml2byte.patch

38 lines
1.6 KiB
Diff
Raw Normal View History

I: Program causes undefined operation
(likely same variable used twiceand post/pre incremented in the same expression).
e.g. x = x++; Split it in two operations.
W: ruby sequence-point yaml2byte.c:67, 104
yaml2byte.c: In function 'bytestring_append':
yaml2byte.c:67:21: warning: operation on 'str->buffer' may be undefined
yaml2byte.c: In function 'bytestring_extend':
yaml2byte.c:104:25: warning: operation on 'str->buffer' may be undefined
#define S_REALLOC_N(var,type,n) (var)=(type*)realloc((char*)(var),sizeof(type)*(n))
so the old code expanded to:
str->buffer = str->buffer = (char*)realloc((char*)str->buffer, sizeof(char)*str->length + 1)
Index: ext/syck/yaml2byte.c
===================================================================
--- ext/syck/yaml2byte.c (revision 27446)
+++ ext/syck/yaml2byte.c (working copy)
@@ -64,7 +64,7 @@
grow = (length - str->remaining) + CHUNKSIZE;
str->remaining += grow;
str->length += grow;
- str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 );
+ S_REALLOC_N( str->buffer, char, str->length + 1 );
assert(str->buffer);
}
curr = str->buffer + (str->length - str->remaining);
@@ -101,7 +101,7 @@
grow = (length - str->remaining) + CHUNKSIZE;
str->remaining += grow;
str->length += grow;
- str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 );
+ S_REALLOC_N( str->buffer, char, str->length + 1 );
}
curr = str->buffer + (str->length - str->remaining);
from = ext->buffer;