[polypaudio-commits] r874 - /trunk/src/polypcore/utf8.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon May 15 17:04:15 PDT 2006


Author: lennart
Date: Tue May 16 02:04:14 2006
New Revision: 874

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=874&root=polypaudio&view=rev
Log:
* fix segfault in pa_utf8_validate()
* remove some compiler warnings
* use our own pa_xmalloc() implementation instead of libc's malloc()

Modified:
    trunk/src/polypcore/utf8.c

Modified: trunk/src/polypcore/utf8.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/utf8.c?rev=874&root=polypaudio&r1=873&r2=874&view=diff
==============================================================================
--- trunk/src/polypcore/utf8.c (original)
+++ trunk/src/polypcore/utf8.c Tue May 16 02:04:14 2006
@@ -34,6 +34,7 @@
 #include <string.h>
 
 #include "utf8.h"
+#include "xmalloc.h"
 
 #define FILTER_CHAR '_'
 
@@ -67,11 +68,11 @@
     int size;
     uint8_t *o;
 
-    o = output;
-    for (p = (uint8_t*)str; *p; p++, o++) {
+    o = (uint8_t*) output;
+    for (p = (const uint8_t*) str; *p; p++) {
         if (*p < 128) {
             if (o)
-                *output = *p;
+                *o = *p;
         } else {
             last = p;
 
@@ -122,6 +123,9 @@
                 o += size - 1;
             }
 
+            if (o)
+                o++;
+            
             continue;
 
 error:
@@ -131,6 +135,9 @@
             } else
                 goto failure;
         }
+
+        if (o)
+            o++;
     }
 
     if (o) {
@@ -151,8 +158,7 @@
 const char* pa_utf8_filter (const char *str) {
     char *new_str;
 
-    new_str = malloc(strlen(str) + 1);
-    assert(new_str);
+    new_str = pa_xnew(char, strlen(str) + 1);
 
     return utf8_validate(str, new_str);
 }




More information about the pulseaudio-commits mailing list