apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-frederic Clere <jfcl...@gmail.com>
Subject apr-iconv (error: invalid lvalue in increment)
Date Thu, 30 Mar 2006 12:47:30 GMT
Hi,

I am trying to compile trunk and I have a problem in apr-iconv the 
corrections are like the patch below.
The memcpy is a bit paranoid, any comments?

Cheers

Jean-frederic

+++
jfclere@vtxclere:~/apr-iconv$ svn diff .
Index: ces/ucs2-internal.c
===================================================================
--- ces/ucs2-internal.c (revision 390028)
+++ ces/ucs2-internal.c (working copy)
@@ -59,7 +59,9 @@
                return -1;      /* No corresponding character in UCS-2 */
        if (*outbytesleft < sizeof(ucs2_t))
                return 0;       /* No space in the output buffer */
-       *((ucs2_t *)(*outbuf))++ = in;
+       /* memcpy prevents addressing problems */
+       *outbuf += sizeof(ucs2_t);
+       memcpy(*outbuf, &in, sizeof(ucs2_t));
        (*outbytesleft) -= sizeof(ucs2_t);
        return 1;
 }
@@ -68,10 +70,14 @@
 convert_to_ucs(struct iconv_ces *ces,
        const unsigned char **inbuf, apr_size_t *inbytesleft)
 {
+       ucs2_t ret;
        if (*inbytesleft < sizeof(ucs2_t))
                return UCS_CHAR_NONE;   /* Not enough bytes in the input 
buffer */
        (*inbytesleft) -= sizeof(ucs2_t);
-       return *((const ucs2_t *)(*inbuf))++;
+       /* memcpy prevents addressing problems */
+       *inbuf += sizeof(ucs2_t);
+       memcpy(&ret, *inbuf, sizeof(ucs2_t));
+       return ret;
 }

 static const struct iconv_ces_desc iconv_ces_desc = {
+++

Mime
View raw message