r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
[vlendec/samba-autobuild/.git] / source3 / web / neg_lang.c
index da974f78a4a0a542bd9a0502179d4683a5e53611..207614655db8a709cb0d547c5309388803307497 100644 (file)
@@ -20,7 +20,7 @@
 */
 
 #include "includes.h"
-#include "../web/swat_proto.h"
+#include "web/swat_proto.h"
 
 /*
   during a file download we first check to see if there is a language
@@ -57,8 +57,8 @@ static int qsort_cmp_list(const void *x, const void *y) {
        struct pri_list *a = (struct pri_list *)x;
        struct pri_list *b = (struct pri_list *)y;
        if (a->pri > b->pri) return -1;
-       if (a->pri == b->pri) return 0;
-       return 1;
+       if (a->pri < b->pri) return 1;
+       return 0;
 }
 
 /*
@@ -85,7 +85,11 @@ void web_set_lang(const char *lang_string)
                count++;
                lang_num++;
        }
-       pl = (struct pri_list *)malloc(sizeof(struct pri_list) * lang_num);
+       pl = SMB_MALLOC_ARRAY(struct pri_list, lang_num);
+       if (!pl) {
+               return;
+       }
+
        for (i = 0; i < lang_num; i++) {
                char *pri_code;
                if ((pri_code=strstr(lang_list[i], ";q="))) {
@@ -95,7 +99,7 @@ void web_set_lang(const char *lang_string)
                } else {
                        pl[i].pri = 1;
                }
-               pl[i].string = strdup(lang_list[i]);
+               pl[i].string = SMB_STRDUP(lang_list[i]);
        }
        str_list_free(&lang_list);