mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
* fix segfault in pa_utf8_validate()
* remove some compiler warnings * use our own pa_xmalloc() implementation instead of libc's malloc() git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@874 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
19167a1a2d
commit
713637cf42
1 changed files with 11 additions and 5 deletions
|
|
@ -34,6 +34,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define FILTER_CHAR '_'
|
#define FILTER_CHAR '_'
|
||||||
|
|
||||||
|
|
@ -67,11 +68,11 @@ static const char* utf8_validate (const char *str, char *output) {
|
||||||
int size;
|
int size;
|
||||||
uint8_t *o;
|
uint8_t *o;
|
||||||
|
|
||||||
o = output;
|
o = (uint8_t*) output;
|
||||||
for (p = (uint8_t*)str; *p; p++, o++) {
|
for (p = (const uint8_t*) str; *p; p++) {
|
||||||
if (*p < 128) {
|
if (*p < 128) {
|
||||||
if (o)
|
if (o)
|
||||||
*output = *p;
|
*o = *p;
|
||||||
} else {
|
} else {
|
||||||
last = p;
|
last = p;
|
||||||
|
|
||||||
|
|
@ -122,6 +123,9 @@ ONE_REMAINING:
|
||||||
o += size - 1;
|
o += size - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (o)
|
||||||
|
o++;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
@ -131,6 +135,9 @@ error:
|
||||||
} else
|
} else
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (o)
|
||||||
|
o++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o) {
|
if (o) {
|
||||||
|
|
@ -151,8 +158,7 @@ const char* pa_utf8_valid (const char *str) {
|
||||||
const char* pa_utf8_filter (const char *str) {
|
const char* pa_utf8_filter (const char *str) {
|
||||||
char *new_str;
|
char *new_str;
|
||||||
|
|
||||||
new_str = malloc(strlen(str) + 1);
|
new_str = pa_xnew(char, strlen(str) + 1);
|
||||||
assert(new_str);
|
|
||||||
|
|
||||||
return utf8_validate(str, new_str);
|
return utf8_validate(str, new_str);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue